Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

chore: replace trivial closures with method paths (Sonar S1612) (#1714)

Dylan M. Taylor8299d264004f
diff --git a/apps/designcraft-cli/src/main.rs b/apps/designcraft-cli/src/main.rs
index 3d18dcaee..faa4f4af0 100644
--- a/apps/designcraft-cli/src/main.rs
+++ b/apps/designcraft-cli/src/main.rs
@@ -263,7 +263,7 @@ impl Export {
/// A name with another extension is an error: it used to get a PNG of the page. One with no
/// extension still does (`--export /dev/stdout`).
fn of(out: &str) -> Result<Self, String> {
- let ext = std::path::Path::new(out).extension().and_then(|e| e.to_str()).map(str::to_lowercase);
+ let ext = std::path::Path::new(out).extension().and_then(std::ffi::OsStr::to_str).map(str::to_lowercase);
Ok(match ext.as_deref() {
None | Some("png" | "jpg" | "jpeg") => Export::Image,
Some("pdf") => Export::Pdf,
diff --git a/apps/designcraft-cli/src/perf.rs b/apps/designcraft-cli/src/perf.rs
index bed57cfcc..0c665f7e7 100644
--- a/apps/designcraft-cli/src/perf.rs
+++ b/apps/designcraft-cli/src/perf.rs
@@ -335,7 +335,7 @@ fn row(rows: &mut Vec<Row>, name: impl Into<String>, ms: f64, budget: Option<f64
/// Measure `doc`. `runs` = repetitions per row (median).
fn measure(doc: &Document, runs: usize) -> Result<Vec<Row>, String> {
let mut rows = vec![];
- let cores = std::thread::available_parallelism().map_or(1, |c| c.get());
+ let cores = std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get);
let chars: usize = doc.stories.values().map(|s| s.text.len()).sum();
// Budget: 250 ms per 300k characters (MT), scaled to this document.
let compose_budget = 250.0 * (chars as f64 / 300_000.0).max(1.0);
@@ -532,7 +532,7 @@ fn print(title: &str, rows: &[Row], noisy: bool) -> Result<(), String> {
}
fn header() -> (usize, bool) {
- let cores = std::thread::available_parallelism().map_or(1, |c| c.get());
+ let cores = std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get);
let load = load_average();
let noisy = load.is_some_and(|l| l > cores as f64 * 0.75);
outln!(
diff --git a/apps/designcraft/src/main.rs b/apps/designcraft/src/main.rs
index e694fe84f..195a2dc6e 100644
--- a/apps/designcraft/src/main.rs
+++ b/apps/designcraft/src/main.rs
@@ -256,7 +256,7 @@ const ALL_FILES: &str = if cfg!(target_os = "macos") { "public.data" } else { "*
/// The extension of the file name a save dialog suggests (`Brochure.designcraft`), if it has one.
/// The dialog filters on it, so the macOS and Windows dialogs add it to a name typed without it.
fn suggested_extension(name: &str) -> Option<&str> {
- std::path::Path::new(name).extension().and_then(|e| e.to_str()).filter(|e| !e.is_empty() && !e.contains(char::is_whitespace))
+ std::path::Path::new(name).extension().and_then(std::ffi::OsStr::to_str).filter(|e| !e.is_empty() && !e.contains(char::is_whitespace))
}
/// The file a save dialog's answer writes: `picked` with the suggested extension added when it has
diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs
index a3fac1eab..15202de7a 100644
--- a/crates/compose/src/lib.rs
+++ b/crates/compose/src/lib.rs
@@ -4040,7 +4040,7 @@ fn hyphenation_points(
// Words repeat a lot: remember their points per set of limits.
static CACHE: Mutex<Vec<(LimitsKey, HashMap<(hyphen::Lang, Box<str>), Box<[usize]>>)>> = Mutex::new(Vec::new());
let key = (lim.min_word, lim.after_first, lim.before_last, lim.capitalized);
- let mut guard = CACHE.lock().unwrap_or_else(|e| e.into_inner());
+ let mut guard = CACHE.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let idx = match guard.iter().position(|e| e.0 == key) {
Some(i) => i,
None => {
@@ -4541,7 +4541,7 @@ pub fn adjacent_row(l: &Line, x: f64, caret_y: f64, up: bool) -> Option<f64> {
// count as still inside the note.
let over = |r: &(f64, f64, f64)| x >= r.1 - 0.01 && x < r.2 - 0.01;
let candidates = rows.iter().filter(|r| over(r)).filter(|r| if up { r.0 < caret_y - ROW_Y } else { r.0 > caret_y + ROW_Y });
- if up { candidates.map(|r| r.0).max_by(|a, b| a.total_cmp(b)) } else { candidates.map(|r| r.0).min_by(|a, b| a.total_cmp(b)) }
+ if up { candidates.map(|r| r.0).max_by(f64::total_cmp) } else { candidates.map(|r| r.0).min_by(f64::total_cmp) }
}
#[cfg(test)]
diff --git a/crates/compose/src/shape.rs b/crates/compose/src/shape.rs
index ffbc4857d..0f739e16e 100644
--- a/crates/compose/src/shape.rs
+++ b/crates/compose/src/shape.rs
@@ -950,10 +950,10 @@ static WORD_CACHE: RwLock<Vec<(WordKey, Arc<RwLock<WordMap>>)>> = RwLock::new(Ve
const WORD_CACHE_MAX: usize = 50_000;
fn word_map(key: WordKey) -> Arc<RwLock<WordMap>> {
- if let Some((_, m)) = WORD_CACHE.read().unwrap_or_else(|e| e.into_inner()).iter().find(|e| e.0 == key) {
+ if let Some((_, m)) = WORD_CACHE.read().unwrap_or_else(std::sync::PoisonError::into_inner).iter().find(|e| e.0 == key) {
return m.clone();
}
- let mut w = WORD_CACHE.write().unwrap_or_else(|e| e.into_inner());
+ let mut w = WORD_CACHE.write().unwrap_or_else(std::sync::PoisonError::into_inner);
if let Some((_, m)) = w.iter().find(|e| e.0 == key) {
return m.clone();
}
diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs
index f9e8ba0fd..3fc1c6ccb 100644
--- a/crates/compose/src/tests.rs
+++ b/crates/compose/src/tests.rs
@@ -1150,7 +1150,7 @@ fn nonbreaking_space_alone_fills_a_justified_line() {
/// Story of `n` one-line filler paragraphs followed by `extra` paragraphs, in a 2-column frame.
fn keep_doc(fillers: usize, extra: &[&str], height: f64) -> (Document, StoryId, Vec<usize>) {
let mut parts: Vec<String> = (0..fillers).map(|k| format!("Filler {k}")).collect();
- parts.extend(extra.iter().map(|s| s.to_string()));
+ parts.extend(extra.iter().map(ToString::to_string));
let text = parts.join("\n");
let (mut d, sid, fid) = doc_with(&text, Rect::new(0.0, 0.0, 400.0, height), ParaAttrs::default());
d.item_mut(fid).unwrap().text_frame_mut().unwrap().options.columns = 2;
diff --git a/crates/doc/src/otf.rs b/crates/doc/src/otf.rs
index 5e246b8bf..64c976bad 100644
--- a/crates/doc/src/otf.rs
+++ b/crates/doc/src/otf.rs
@@ -53,7 +53,7 @@ pub fn figures(list: &[String]) -> &'static str {
pub fn set_figures(list: &mut Vec<String>, id: &str) -> bool {
let Some((_, _, tags, _)) = FIGURES.iter().find(|f| f.0 == id) else { return false };
list.retain(|t| !matches!(t.as_str(), "tnum" | "pnum" | "lnum" | "onum"));
- list.extend(tags.iter().map(|t| t.to_string()));
+ list.extend(tags.iter().map(ToString::to_string));
true
}
diff --git a/crates/engine/src/cmd/book.rs b/crates/engine/src/cmd/book.rs
index 4a65137cf..18f554d57 100644
--- a/crates/engine/src/cmd/book.rs
+++ b/crates/engine/src/cmd/book.rs
@@ -130,7 +130,7 @@ impl ChapterBatch {
fn writable_chapter(s: &Session, path: &str, command: &'static str) -> Result<()> {
use std::path::Path;
- if Path::new(path).extension().and_then(|ext| ext.to_str()).is_some_and(|ext| ext.eq_ignore_ascii_case("idml")) {
+ if Path::new(path).extension().and_then(std::ffi::OsStr::to_str).is_some_and(|ext| ext.eq_ignore_ascii_case("idml")) {
return Err(bad(command, format!("cannot change imported IDML chapter {path}; convert it to a native DesignCraft document first")));
}
let target = crate::io::canonicalize(path).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
diff --git a/crates/engine/src/cmd/datamerge/fill.rs b/crates/engine/src/cmd/datamerge/fill.rs
index b0165d9d3..d4b2235e9 100644
--- a/crates/engine/src/cmd/datamerge/fill.rs
+++ b/crates/engine/src/cmd/datamerge/fill.rs
@@ -254,7 +254,7 @@ fn find_markers(text: &str) -> Vec<(usize, usize, String)> {
continue;
}
}
- i += text[i..].chars().next().map(|c| c.len_utf8()).unwrap_or(1);
+ i += text[i..].chars().next().map(char::len_utf8).unwrap_or(1);
}
out
}
diff --git a/crates/engine/src/cmd/datamerge/mod.rs b/crates/engine/src/cmd/datamerge/mod.rs
index 38b543ff7..c07e2fff4 100644
--- a/crates/engine/src/cmd/datamerge/mod.rs
+++ b/crates/engine/src/cmd/datamerge/mod.rs
@@ -617,7 +617,7 @@ fn marker_ranges(text: &str, marker: &str) -> Vec<(usize, usize)> {
i = end;
continue;
}
- i = i.saturating_add(text[i..].chars().next().map(|c| c.len_utf8()).unwrap_or(1));
+ i = i.saturating_add(text[i..].chars().next().map(char::len_utf8).unwrap_or(1));
}
out
}
diff --git a/crates/engine/src/cmd/datamerge/parse.rs b/crates/engine/src/cmd/datamerge/parse.rs
index 61ad6224e..c76c37f1e 100644
--- a/crates/engine/src/cmd/datamerge/parse.rs
+++ b/crates/engine/src/cmd/datamerge/parse.rs
@@ -379,7 +379,7 @@ fn sniff(name: &str, text: &str) -> Delimiter {
}
pub fn extension(name: &str) -> String {
- Path::new(name).extension().and_then(|e| e.to_str()).unwrap_or("").to_ascii_lowercase()
+ Path::new(name).extension().and_then(std::ffi::OsStr::to_str).unwrap_or("").to_ascii_lowercase()
}
struct HeaderDelimiterCandidate {
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index c644284d1..bc6928362 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -166,7 +166,7 @@ fn save_bytes(d: &Document, preview: Option<&[u8]>) -> Result<Vec<u8>> {
/// the file opens from the file manager. A path without a file name is left for the write to fail.
pub fn with_document_extension(path: &str) -> String {
let p = std::path::Path::new(path);
- let ext = p.extension().and_then(|e| e.to_str());
+ let ext = p.extension().and_then(std::ffi::OsStr::to_str);
if p.file_name().is_none() || ext.is_some_and(|e| e.eq_ignore_ascii_case(designcraft_format::EXTENSION)) {
return path.to_string();
}
@@ -469,7 +469,7 @@ fn open_path(s: &mut Session, p: &Value) -> Result<Value> {
let bytes = crate::io::read_file(path).map_err(EngineError::Other)?;
// The content decides first: a file's extension may be missing or wrong. The extension
// then routes files whose content isn't recognised to the reader that explains why.
- let ext = std::path::Path::new(path).extension().and_then(|e| e.to_str()).unwrap_or_default().to_ascii_lowercase();
+ let ext = std::path::Path::new(path).extension().and_then(std::ffi::OsStr::to_str).unwrap_or_default().to_ascii_lowercase();
let native = designcraft_format::is_designcraft(&bytes) || bytes.trim_ascii_start().starts_with(b"{");
if designcraft_idml::is_idml(&bytes) || (!native && (super::interchange::is_indd(path, &bytes) || ext == "idml")) {
return super::interchange::open_idml(s, p);
diff --git a/crates/engine/src/cmd/links.rs b/crates/engine/src/cmd/links.rs
index b2cb88fd2..c39e05668 100644
--- a/crates/engine/src/cmd/links.rs
+++ b/crates/engine/src/cmd/links.rs
@@ -480,7 +480,7 @@ fn relink_folder(s: &mut Session, p: &Value) -> Result<Value> {
continue;
}
let old = std::path::PathBuf::from(a.link.clone().unwrap_or_else(|| a.name.clone()));
- let mut name = old.file_name().map(|n| n.to_os_string()).unwrap_or_else(|| a.name.clone().into());
+ let mut name = old.file_name().map(std::ffi::OsStr::to_os_string).unwrap_or_else(|| a.name.clone().into());
if let Some(e) = &ext {
name = std::path::Path::new(&name).with_extension(e).into_os_string();
}
diff --git a/crates/engine/src/guard.rs b/crates/engine/src/guard.rs
index 2ac6bb63c..6395c3594 100644
--- a/crates/engine/src/guard.rs
+++ b/crates/engine/src/guard.rs
@@ -13,7 +13,7 @@ use crate::{EngineError, Result, Session};
pub fn panic_message(payload: &(dyn std::any::Any + Send)) -> String {
payload
.downcast_ref::<&str>()
- .map(|s| s.to_string())
+ .map(ToString::to_string)
.or_else(|| payload.downcast_ref::<String>().cloned())
.unwrap_or_else(|| "unknown panic".into())
}
diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rs
index 0c3d229c3..1c1e55bd1 100644
--- a/crates/fonts/src/fontdb.rs
+++ b/crates/fonts/src/fontdb.rs
@@ -1314,7 +1314,7 @@ impl FontDb {
stack.push(p);
continue;
}
- let ext = p.extension().and_then(|e| e.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;
}
@@ -1399,7 +1399,7 @@ impl FontDb {
let Ok(entries) = std::fs::read_dir(folder) else { return out };
let mut files: Vec<std::path::PathBuf> = Vec::new();
for path in entries.flatten().map(|e| e.path()) {
- let ext = path.extension().and_then(|e| e.to_str()).map(|e| e.to_ascii_lowercase());
+ let ext = path.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/geom/src/trace.rs b/crates/geom/src/trace.rs
index b2d850ea9..54809fbb5 100644
--- a/crates/geom/src/trace.rs
+++ b/crates/geom/src/trace.rs
@@ -36,12 +36,12 @@ pub fn trace(mask: &[bool], w: usize, h: usize, tol: f64, min_area: f64) -> Vec<
let mut starts: Vec<(isize, isize)> = next.keys().copied().collect();
starts.sort();
for s in starts {
- while let Some(first) = next.get_mut(&s).and_then(|v| v.pop()) {
+ while let Some(first) = next.get_mut(&s).and_then(Vec::pop) {
let mut ring = vec![s];
let mut cur = first;
while cur != s {
ring.push(cur);
- match next.get_mut(&cur).and_then(|v| v.pop()) {
+ match next.get_mut(&cur).and_then(Vec::pop) {
Some(n) => cur = n,
None => break,
}
diff --git a/crates/idml/src/export.rs b/crates/idml/src/export.rs
index d3587c943..ef692bfa4 100644
--- a/crates/idml/src/export.rs
+++ b/crates/idml/src/export.rs
@@ -177,7 +177,7 @@ impl<'a> Ex<'a> {
}
fn assign_swatch_ids(&mut self) {
- let mut used: HashSet<String> = ["Swatch/None", "Color/Paper", "Color/Black", "Color/Registration"].iter().map(|s| s.to_string()).collect();
+ let mut used: HashSet<String> = ["Swatch/None", "Color/Paper", "Color/Black", "Color/Registration"].iter().map(ToString::to_string).collect();
self.swatch_ids.insert(swatch::NONE.into(), "Swatch/None".into());
self.swatch_ids.insert(swatch::PAPER.into(), "Color/Paper".into());
self.swatch_ids.insert(swatch::BLACK.into(), "Color/Black".into());
diff --git a/crates/images/src/psd.rs b/crates/images/src/psd.rs
index db11eef5a..980f802c5 100644
--- a/crates/images/src/psd.rs
+++ b/crates/images/src/psd.rs
@@ -298,7 +298,7 @@ impl<'a> ImageData<'a> {
}
let mut counts = self.counts.chunks_exact(self.count_size).map(|c| c.iter().fold(0usize, |n, &b| n << 8 | usize::from(b)));
// This channel starts after every earlier channel's rows.
- let mut at = counts.by_ref().take(ch.checked_mul(self.height)?).try_fold(0usize, |at, n| at.checked_add(n))?;
+ let mut at = counts.by_ref().take(ch.checked_mul(self.height)?).try_fold(0usize, usize::checked_add)?;
for _ in 0..self.height {
let n = counts.next()?;
let end = at.checked_add(n)?;
diff --git a/crates/pdf/src/lib.rs b/crates/pdf/src/lib.rs
index ad1123897..66512ac50 100644
--- a/crates/pdf/src/lib.rs
+++ b/crates/pdf/src/lib.rs
@@ -56,7 +56,7 @@ pub enum Standard {
impl Standard {
/// `none`, `x4` / `pdfx4` / `PDF/X-4`, `a2b` / `pdfa2b` / `PDF/A-2b`.
pub fn parse(s: &str) -> Option<Self> {
- let k: String = s.chars().filter(|c| c.is_ascii_alphanumeric()).collect::<String>().to_ascii_lowercase();
+ let k: String = s.chars().filter(char::is_ascii_alphanumeric).collect::<String>().to_ascii_lowercase();
match k.as_str() {
"" | "none" => Some(Self::None),
"x4" | "pdfx4" | "pdfx42008" | "pdfx42010" => Some(Self::PdfX4),
diff --git a/crates/pdf/src/pdfx.rs b/crates/pdf/src/pdfx.rs
index 2be38f97a..9aaeb445a 100644
--- a/crates/pdf/src/pdfx.rs
+++ b/crates/pdf/src/pdfx.rs
@@ -285,7 +285,7 @@ fn device_rgb(pdf: &[u8]) -> Vec<String> {
found
.into_iter()
.map(|(what, pages)| {
- let list: Vec<String> = pages.iter().take(10).map(|p| p.to_string()).collect();
+ let list: Vec<String> = pages.iter().take(10).map(ToString::to_string).collect();
let more = if pages.len() > 10 { ", …" } else { "" };
let s = if pages.len() == 1 { "" } else { "s" };
format!("{what} on page{s} {}{more}: under a CMYK output intent RGB needs an ICC profile", list.join(", "))
diff --git a/crates/pdf/src/pdfx/fonts.rs b/crates/pdf/src/pdfx/fonts.rs
index 5dc149b7f..83178682a 100644
--- a/crates/pdf/src/pdfx/fonts.rs
+++ b/crates/pdf/src/pdfx/fonts.rs
@@ -33,7 +33,7 @@ pub(super) fn unembedded_fonts(pdf: &[u8]) -> Vec<String> {
let mut warnings: Vec<String> = found
.into_iter()
.map(|(name, pages)| {
- let list: Vec<String> = pages.iter().take(10).map(|p| p.to_string()).collect();
+ let list: Vec<String> = pages.iter().take(10).map(ToString::to_string).collect();
let more = if pages.len() > 10 { ", …" } else { "" };
let s = if pages.len() == 1 { "" } else { "s" };
format!("the font {name} isn't embedded (page{s} {}{more}): PDF/X-4 needs every font used for visible text embedded", list.join(", "))
diff --git a/crates/render/src/blendspace.rs b/crates/render/src/blendspace.rs
index 79c476343..f6c2fa328 100644
--- a/crates/render/src/blendspace.rs
+++ b/crates/render/src/blendspace.rs
@@ -240,7 +240,7 @@ fn srgb_table() -> std::sync::Arc<Vec<[f32; 3]>> {
type Lut = (designcraft_color::cms::ColorSettings, std::sync::Arc<Vec<[f32; 3]>>);
static LUT: std::sync::Mutex<Option<Lut>> = std::sync::Mutex::new(None);
let settings = designcraft_color::cms::active_settings();
- let mut g = LUT.lock().unwrap_or_else(|e| e.into_inner());
+ let mut g = LUT.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
match g.as_ref() {
Some((s, t)) if *s == settings => t.clone(),
_ => {
diff --git a/crates/render/src/images.rs b/crates/render/src/images.rs
index 4a6052781..37606097d 100644
--- a/crates/render/src/images.rs
+++ b/crates/render/src/images.rs
@@ -56,7 +56,7 @@ fn size_of(pm: &Pixmap) -> usize {
}
fn with<R>(f: impl FnOnce(&mut Cache) -> R) -> R {
- let mut g = CACHE.lock().unwrap_or_else(|e| e.into_inner());
+ let mut g = CACHE.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let c = g.get_or_insert_with(Cache::default);
// Decoding converts CMYK through the working space: new colour settings, new pixels.
let colour = designcraft_color::cms::generation();
diff --git a/crates/render/src/pdf_layers.rs b/crates/render/src/pdf_layers.rs
index 2573598d9..3b323a505 100644
--- a/crates/render/src/pdf_layers.rs
+++ b/crates/render/src/pdf_layers.rs
@@ -236,7 +236,7 @@ pub(crate) fn layered(data: &Arc<Vec<u8>>, hidden: &[String]) -> Option<Arc<Vec<
type Key = (usize, Vec<String>);
static CACHE: Mutex<Option<HashMap<Key, (Arc<Vec<u8>>, Option<Arc<Vec<u8>>>)>>> = Mutex::new(None);
let key = (Arc::as_ptr(data) as usize, hidden.to_vec());
- let mut c = CACHE.lock().unwrap_or_else(|e| e.into_inner());
+ let mut c = CACHE.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let map = c.get_or_insert_with(HashMap::new);
if let Some(v) = map.get(&key) {
return v.1.clone();
diff --git a/crates/textimport/src/xlsx.rs b/crates/textimport/src/xlsx.rs
index 3f20f3dee..83bea3c87 100644
--- a/crates/textimport/src/xlsx.rs
+++ b/crates/textimport/src/xlsx.rs
@@ -11,7 +11,7 @@ use crate::{ImportError, Imported};
/// "B12" → (row 11, column 1).
fn cell_ref(r: &str) -> Option<(usize, usize)> {
- let letters: String = r.chars().take_while(|c| c.is_ascii_alphabetic()).collect();
+ let letters: String = r.chars().take_while(char::is_ascii_alphabetic).collect();
let row: usize = r[letters.len()..].parse().ok()?;
let col = letters.chars().try_fold(0usize, |acc, c| {
let digit = (c.to_ascii_uppercase() as u8).checked_sub(b'A')? as usize + 1;
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index b149cea64..6a60da26e 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -1071,7 +1071,7 @@ impl DesignApp {
}
}
let Some(inbox) = self.services.inbox.clone() else { return };
- let files = std::mem::take(&mut *inbox.lock().unwrap_or_else(|e| e.into_inner()));
+ let files = std::mem::take(&mut *inbox.lock().unwrap_or_else(std::sync::PoisonError::into_inner));
for file in files {
if file.request.purpose == "shortcuts" {
shortcut_import::import_delivered(self, &file.bytes);
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index d97dcdeba..3c052b783 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -1933,7 +1933,7 @@ fn run_ui_inner(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value
"Typography" => Some(TYPOGRAPHY_GROUPS),
_ => None,
};
- app.ui.icon_groups = groups.map(|groups| groups.iter().map(|g| g.iter().map(|p| p.to_string()).collect()).collect());
+ app.ui.icon_groups = groups.map(|groups| groups.iter().map(|g| g.iter().map(ToString::to_string).collect()).collect());
app.ui.dock_expanded = groups.is_none();
let dock_tab = match name {
"Interactive for PDF" | "Digital Publishing" => Some("pages"),
diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rs
index f2229b604..85058d7a8 100644
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@ -264,7 +264,7 @@ pub fn preflight_errors(app: &DesignApp) -> usize {
static MEMO: std::sync::Mutex<Option<(usize, usize)>> = std::sync::Mutex::new(None);
let Some(st) = app.session.active() else { return 0 };
let key = std::sync::Arc::as_ptr(&st.doc) as usize;
- let mut g = MEMO.lock().unwrap_or_else(|e| e.into_inner());
+ let mut g = MEMO.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
if let Some((k, n)) = *g
&& k == key
{
diff --git a/crates/ui-egui/src/panels/pages.rs b/crates/ui-egui/src/panels/pages.rs
index 4b2360f8f..534eb4aa1 100644
--- a/crates/ui-egui/src/panels/pages.rs
+++ b/crates/ui-egui/src/panels/pages.rs
@@ -28,7 +28,7 @@ const MAX_THUMB_W: f64 = 1024.0;
fn thumb(app: &mut DesignApp, ctx: &egui::Context, of: ThumbOf, h: f32) -> Option<egui::TextureHandle> {
let st = app.session.active()?;
let key = (st.uid, st.revision, of, h.round() as u32);
- let mut g = THUMBS.lock().unwrap_or_else(|e| e.into_inner());
+ let mut g = THUMBS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let map = g.get_or_insert_with(HashMap::new);
if let Some(t) = map.get(&key) {
return Some(t.clone());
diff --git a/xtask/src/assets.rs b/xtask/src/assets.rs
index 1aef2dbac..e0074b9e0 100644
--- a/xtask/src/assets.rs
+++ b/xtask/src/assets.rs
@@ -42,7 +42,7 @@ const ASSET_EXT: &[&str] = &[
const ASSET_DIRS: &[&str] = &["assets/", "docs/images/", "examples/"];
pub fn is_asset(path: &str) -> bool {
- let ext = Path::new(path).extension().and_then(|e| e.to_str()).map(str::to_ascii_lowercase).unwrap_or_default();
+ let ext = Path::new(path).extension().and_then(std::ffi::OsStr::to_str).map(str::to_ascii_lowercase).unwrap_or_default();
ASSET_DIRS.iter().any(|d| path.starts_with(d)) || ASSET_EXT.contains(&ext.as_str())
}
diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs
index dbfbfb5c8..8355fb95d 100644
--- a/xtask/src/layers.rs
+++ b/xtask/src/layers.rs
@@ -194,7 +194,7 @@ pub fn check(crates: &[Crate]) -> Vec<Violation> {
}
}
}
- out.sort_by_key(|v| v.to_string());
+ out.sort_by_key(ToString::to_string);
out.dedup();
out
}