Make clippy a bit happier

This commit is contained in:
Laurenz 2021-06-30 11:48:51 +02:00
parent 470f8001a1
commit 65c0c5607e
5 changed files with 8 additions and 7 deletions

View File

@ -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<ImageId, Image>,
@ -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.

View File

@ -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.

View File

@ -285,7 +285,7 @@ fn split_runs<'a>(
range: Range,
) -> impl Iterator<Item = (Range, Dir)> + '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;

View File

@ -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

View File

@ -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,
}
}