diff --git a/apps/wordcraft/src/file_dialogs.rs b/apps/wordcraft/src/file_dialogs.rs index 27c534971..667298a72 100644 --- a/apps/wordcraft/src/file_dialogs.rs +++ b/apps/wordcraft/src/file_dialogs.rs @@ -208,7 +208,7 @@ fn save_exts(name: &str) -> Vec { let suggested = std::path::Path::new(name) .extension() .and_then(std::ffi::OsStr::to_str) - .map(|e| e.to_ascii_lowercase()) + .map(str::to_ascii_lowercase) .filter(|e| wordcraft_engine::io::SAVE_EXTS.contains(&e.as_str())) .unwrap_or_else(|| "docx".to_string()); let mut exts: Vec = Vec::with_capacity(wordcraft_engine::io::SAVE_EXTS.len()); diff --git a/crates/doc/src/cjk_numbers.rs b/crates/doc/src/cjk_numbers.rs index f3b6585c4..bdb1fbe65 100644 --- a/crates/doc/src/cjk_numbers.rs +++ b/crates/doc/src/cjk_numbers.rs @@ -238,7 +238,7 @@ pub(crate) fn ideograph_zodiac_traditional(n: u32) -> String { /// The `n`th (1-based) item of a sequence, or decimal past its end. fn nth(set: &[char], n: u32) -> String { - n.checked_sub(1).and_then(|i| set.get(i as usize)).map(|c| c.to_string()).unwrap_or_else(|| n.to_string()) + n.checked_sub(1).and_then(|i| set.get(i as usize)).map(ToString::to_string).unwrap_or_else(|| n.to_string()) } /// Code points `first..` enclosing 1 to `count`, decimal beyond. diff --git a/crates/docbin/src/piece.rs b/crates/docbin/src/piece.rs index 00a34c323..a7274c9d9 100644 --- a/crates/docbin/src/piece.rs +++ b/crates/docbin/src/piece.rs @@ -113,7 +113,7 @@ impl PieceTable { } PrmRef::Sprm0 { isprm, val: (p.prm >> 8) as u8 } } else { - PrmRef::Grpprl(self.prc_grpprls.get((p.prm >> 1) as usize).map(|v| v.as_slice())) + PrmRef::Grpprl(self.prc_grpprls.get((p.prm >> 1) as usize).map(Vec::as_slice)) } } diff --git a/crates/docx/src/read/story.rs b/crates/docx/src/read/story.rs index 2048ea30d..f948239d3 100644 --- a/crates/docx/src/read/story.rs +++ b/crates/docx/src/read/story.rs @@ -2291,7 +2291,7 @@ fn css_string(v: &str) -> String { out.push(d); } // One whitespace after the escape is its terminator, not part of the value. - if chars.clone().next().is_some_and(|w| w.is_whitespace()) { + if chars.clone().next().is_some_and(char::is_whitespace) { chars.next(); } } diff --git a/crates/docx/src/write/embed.rs b/crates/docx/src/write/embed.rs index 56f3a7898..6e0495614 100644 --- a/crates/docx/src/write/embed.rs +++ b/crates/docx/src/write/embed.rs @@ -68,7 +68,7 @@ impl<'d> EmbedWriter<'d> { "[content_types].xml", ] .iter() - .map(|s| s.to_string()) + .map(ToString::to_string) .collect(); taken.insert(VBA_PROJECT_PART.to_ascii_lowercase()); // The bibliography writer uses these names when sources are present (#532). diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rs index abfc5b2f6..6d3dc1a6c 100644 --- a/crates/fonts/src/fontdb.rs +++ b/crates/fonts/src/fontdb.rs @@ -1243,7 +1243,7 @@ impl FontDb { stack.push(p); continue; } - let ext = p.extension().and_then(std::ffi::OsStr::to_str).map(|e| e.to_ascii_lowercase()); + let ext = p.extension().and_then(std::ffi::OsStr::to_str).map(str::to_ascii_lowercase); if !matches!(ext.as_deref(), Some("ttf" | "otf" | "ttc" | "otc")) { continue; } diff --git a/crates/fonts/src/ui_fallback.rs b/crates/fonts/src/ui_fallback.rs index 12a4a1a1d..3ef38e55b 100644 --- a/crates/fonts/src/ui_fallback.rs +++ b/crates/fonts/src/ui_fallback.rs @@ -182,7 +182,7 @@ pub(crate) fn find_ui_font(dirs: &[std::path::PathBuf], names: &[&str], needed: if !tried.insert(path.clone()) { continue; } - let Some(size) = std::fs::metadata(&path).ok().filter(|m| m.is_file()).map(|m| m.len()) else { continue }; + let Some(size) = std::fs::metadata(&path).ok().filter(std::fs::Metadata::is_file).map(|m| m.len()) else { continue }; if size > MAX_FILE { continue; } diff --git a/crates/formats/src/odt.rs b/crates/formats/src/odt.rs index e1f0fd886..8abf06cb8 100644 --- a/crates/formats/src/odt.rs +++ b/crates/formats/src/odt.rs @@ -440,7 +440,7 @@ impl Writer { /// Paragraph `p`, or with `chain` the paragraphs joined at deleted paragraph marks (`p` /// is the first). fn para_in(&mut self, p: &Para, chain: Option<&Vec>, out: &mut String) { - let paras: &[Para] = chain.map(|c| c.as_slice()).unwrap_or(std::slice::from_ref(p)); + let paras: &[Para] = chain.map(Vec::as_slice).unwrap_or(std::slice::from_ref(p)); let start = self.master.take(); self.chain = chain.map(|c| c.iter().map(|q| self.para_style(q)).collect()).unwrap_or_default(); self.part = 0; diff --git a/crates/layout/src/lib.rs b/crates/layout/src/lib.rs index f7d4b9b34..3068f6d20 100644 --- a/crates/layout/src/lib.rs +++ b/crates/layout/src/lib.rs @@ -1304,7 +1304,7 @@ fn layout_box( let float_y = if float.v_rel == Anchor::Paragraph { para_top } else { y }; let r = float_rect(frame, (0.0, width), float_y, w, h, float); let outline = ctx.wrap_outline(o); - excl.extend(wrap_area(r, float, outline.as_deref().map(|v| v.as_slice()))); + excl.extend(wrap_area(r, float, outline.as_deref().map(Vec::as_slice))); floats.insert(oi, r); } let rel = rel_exclusions(&excl, 0.0, y); @@ -3045,8 +3045,8 @@ impl PageFrame<'_> { /// Alignment `a` across the page: inside and outside become right and left on an even page. fn h_align(frame: Option<&Self>, a: Option) -> Option { match a { - Some(FloatAlign::Inside) if frame.is_some_and(|f| f.even()) => Some(FloatAlign::End), - Some(FloatAlign::Outside) if frame.is_some_and(|f| f.even()) => Some(FloatAlign::Start), + Some(FloatAlign::Inside) if frame.is_some_and(Self::even) => Some(FloatAlign::End), + Some(FloatAlign::Outside) if frame.is_some_and(Self::even) => Some(FloatAlign::Start), a => a, } } @@ -3365,7 +3365,7 @@ fn anchor_floats( // Positions relative to the paragraph start above its space before (Word for Windows). let mut r = float_rect(Some(frame), (col_x, width), y0 - before, w, h, float); let outline = ctx.wrap_outline(o); - let outline = outline.as_deref().map(|v| v.as_slice()); + let outline = outline.as_deref().map(Vec::as_slice); let mut area = wrap_area(r, float, outline); if pb.settle && text_before { let seed = early.and_then(|v| v.iter().find(|(b, k, _)| (*b, *k) == (block, oi))).map(|(_, _, a)| a); diff --git a/crates/layout/src/math.rs b/crates/layout/src/math.rs index 6180fad39..7291e89dd 100644 --- a/crates/layout/src/math.rs +++ b/crates/layout/src/math.rs @@ -1518,7 +1518,7 @@ impl Ctx { } segs_rows.push(segs.into_iter().map(hcat).collect()); } - let ncols = segs_rows.iter().map(|r| r.len()).max().unwrap_or(1); + let ncols = segs_rows.iter().map(Vec::len).max().unwrap_or(1); // Rows without `&` are centred below, so they don't widen the aligned columns. let mut col_w = vec![0.0f32; ncols]; let mut lone_w = 0.0f32; @@ -1829,7 +1829,7 @@ impl Ctx { } cells.push(row); } - let ncols = cells.iter().map(|r| r.len()).max().unwrap_or(0); + let ncols = cells.iter().map(Vec::len).max().unwrap_or(0); let mut col_w = vec![0.0f32; ncols]; for r in &cells { for (i, b) in r.iter().enumerate() { diff --git a/crates/metafile/src/geom.rs b/crates/metafile/src/geom.rs index 8063c730a..0547de18b 100644 --- a/crates/metafile/src/geom.rs +++ b/crates/metafile/src/geom.rs @@ -103,7 +103,7 @@ pub(crate) fn subpaths(pts: &[P], counts: &[usize], close: bool) -> Vec { let mut at = 0usize; for &c in counts { let end = at.saturating_add(c).min(pts.len()); - let Some((first, rest)) = pts.get(at..end).and_then(|s| s.split_first()) else { + let Some((first, rest)) = pts.get(at..end).and_then(<[_]>::split_first) else { at = end; continue; }; diff --git a/crates/proof/src/affix.rs b/crates/proof/src/affix.rs index 1839a1034..c2580bca7 100644 --- a/crates/proof/src/affix.rs +++ b/crates/proof/src/affix.rs @@ -419,7 +419,7 @@ impl AffixDict { } stems.push((word, flags)); } - AffixDict::build(rules, stems, comments.iter().map(|s| s.to_string()).collect()) + AffixDict::build(rules, stems, comments.iter().map(ToString::to_string).collect()) } fn build(rules: Rules, mut stems: Vec<(String, String)>, comments: Vec) -> Result { diff --git a/crates/ui-egui/examples/perf_probe.rs b/crates/ui-egui/examples/perf_probe.rs index b2ef7fc42..1ea778f3d 100644 --- a/crates/ui-egui/examples/perf_probe.rs +++ b/crates/ui-egui/examples/perf_probe.rs @@ -27,7 +27,7 @@ fn step(h: &mut egui_kittest::Harness<'_, WordApp>) -> f64 { fn stats(v: &[f64]) -> serde_json::Value { let mut s = v.to_vec(); - s.sort_by(|a, b| a.total_cmp(b)); + s.sort_by(f64::total_cmp); let at = |q: f64| s.get(((s.len() as f64 - 1.0) * q).round() as usize).copied().unwrap_or(0.0); json!({"n": s.len(), "med": (at(0.5) * 10.0).round() / 10.0, "p95": (at(0.95) * 10.0).round() / 10.0, "max": (at(1.0) * 10.0).round() / 10.0}) } diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs index a1f43d86f..ee0e69e47 100644 --- a/xtask/src/layers.rs +++ b/xtask/src/layers.rs @@ -192,7 +192,7 @@ pub fn check(crates: &[Crate]) -> Vec { } } } - out.sort_by_key(|v| v.to_string()); + out.sort_by_key(ToString::to_string); out.dedup(); out }