diff --git a/src/image.rs b/src/image.rs index 90252ff33..f4617c5a1 100644 --- a/src/image.rs +++ b/src/image.rs @@ -54,6 +54,7 @@ impl Debug for Image { } /// Caches decoded images. +#[derive(Default)] pub struct ImageCache { /// Maps from file hashes to ids of decoded images. images: HashMap, @@ -64,7 +65,7 @@ pub struct ImageCache { impl ImageCache { /// Create a new, empty image cache. pub fn new() -> Self { - Self { images: HashMap::new(), on_load: None } + Self::default() } /// Load and decode an image file from a path. diff --git a/src/layout/incremental.rs b/src/layout/incremental.rs index 1dd90f8ed..d41fe4314 100644 --- a/src/layout/incremental.rs +++ b/src/layout/incremental.rs @@ -21,7 +21,7 @@ pub struct LayoutCache { impl LayoutCache { /// Create a new, empty layout cache. pub fn new() -> Self { - Self { frames: HashMap::new(), age: 0 } + Self::default() } /// Clear the cache. diff --git a/src/layout/par.rs b/src/layout/par.rs index 464853e02..340167371 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -285,7 +285,7 @@ fn split_runs<'a>( range: Range, ) -> impl Iterator + 'a { let mut cursor = range.start; - bidi.levels[range.clone()] + bidi.levels[range] .group_by_key(|&level| level) .map(move |(level, group)| { let start = cursor; diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs index 021e9eccc..2496aae0f 100644 --- a/src/layout/shaping.rs +++ b/src/layout/shaping.rs @@ -235,9 +235,8 @@ fn shape_segment<'a>( } } - match ctx.cache.font.select(ctx.loader, family, variant) { - Some(id) => break (id, true), - None => {} + if let Some(id) = ctx.cache.font.select(ctx.loader, family, variant) { + break (id, true); } } // We're out of families, so we don't do any more fallback and just diff --git a/src/library/text.rs b/src/library/text.rs index 28ca2bd83..bf0d49a49 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -204,7 +204,8 @@ pub fn lang(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { fn lang_dir(iso: &str) -> Dir { match iso.to_ascii_lowercase().as_str() { "ar" | "he" | "fa" | "ur" | "ps" | "yi" => Dir::RTL, - "en" | "fr" | "de" | _ => Dir::LTR, + "en" | "fr" | "de" => Dir::LTR, + _ => Dir::LTR, } }