From a906fd298f37d3b23ad9fe7f2ebf6e0a47f36cf4 Mon Sep 17 00:00:00 2001 From: Aloxaf Date: Thu, 13 Oct 2022 15:11:41 +0800 Subject: [PATCH] fix: make clippy happy --- Cargo.lock | 2 +- src/assets.rs | 4 ++-- src/bin/silicon/config.rs | 8 ++++---- src/bin/silicon/main.rs | 2 +- src/blur.rs | 1 + src/utils.rs | 8 ++++---- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ec5c2f..6bf95f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1273,7 +1273,7 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "silicon" -version = "0.4.3" +version = "0.5.0" dependencies = [ "anyhow", "clipboard", diff --git a/src/assets.rs b/src/assets.rs index 4afd5f4..d5e2673 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -6,8 +6,8 @@ use syntect::dumps; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSet; -const DEFAULT_SYNTAXSET: &'static [u8] = include_bytes!("../assets/syntaxes.bin"); -const DEFAULT_THEMESET: &'static [u8] = include_bytes!("../assets/themes.bin"); +const DEFAULT_SYNTAXSET: &[u8] = include_bytes!("../assets/syntaxes.bin"); +const DEFAULT_THEMESET: &[u8] = include_bytes!("../assets/themes.bin"); pub struct HighlightingAssets { pub syntax_set: SyntaxSet, diff --git a/src/bin/silicon/config.rs b/src/bin/silicon/config.rs index 9fc9849..af7385e 100644 --- a/src/bin/silicon/config.rs +++ b/src/bin/silicon/config.rs @@ -30,7 +30,7 @@ pub fn get_args_from_config_file() -> Vec { .split('\n') .map(|line| line.trim()) .filter(|line| !line.starts_with('#') && !line.is_empty()) - .map(|line| shell_words::split(line)) + .map(shell_words::split) .collect::, _>>() .ok() }) @@ -39,8 +39,8 @@ pub fn get_args_from_config_file() -> Vec { } fn parse_str_color(s: &str) -> Result, Error> { - Ok(s.to_rgba() - .map_err(|_| format_err!("Invalid color: `{}`", s))?) + s.to_rgba() + .map_err(|_| format_err!("Invalid color: `{}`", s)) } fn parse_font_str(s: &str) -> Vec<(String, f32)> { @@ -301,7 +301,7 @@ impl Config { if let (Ok(home_dir), true) = (std::env::var("HOME"), need_expand) { self.output .as_ref() - .map(|p| p.to_string_lossy().replacen("~", &home_dir, 1).into()) + .map(|p| p.to_string_lossy().replacen('~', &home_dir, 1).into()) } else { self.output.clone() } diff --git a/src/bin/silicon/main.rs b/src/bin/silicon/main.rs index 4d77d57..e03a7ed 100644 --- a/src/bin/silicon/main.rs +++ b/src/bin/silicon/main.rs @@ -27,7 +27,7 @@ pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> { let mut temp = tempfile::NamedTempFile::new()?; image.write_to(&mut temp, ImageOutputFormat::Png)?; Command::new("xclip") - .args(&[ + .args([ "-sel", "clip", "-t", diff --git a/src/blur.rs b/src/blur.rs index 2b2e7fc..883309f 100644 --- a/src/blur.rs +++ b/src/blur.rs @@ -14,6 +14,7 @@ struct SharedMutPtr(*mut [[u8; 4]]); unsafe impl Sync for SharedMutPtr {} impl SharedMutPtr { + #[allow(clippy::mut_from_ref)] unsafe fn get(&self) -> &mut [[u8; 4]] { &mut *self.0 } diff --git a/src/utils.rs b/src/utils.rs index 29e9515..5145cfb 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -265,16 +265,16 @@ pub(crate) fn round_corner(image: &mut DynamicImage, radius: u32) { foreground, ); - let part = crop_imm(&mut circle, 0, 0, radius, radius); + let part = crop_imm(&circle, 0, 0, radius, radius); image.copy_from(&*part, 0, 0).unwrap(); - let part = crop_imm(&mut circle, radius + 1, 0, radius, radius); + let part = crop_imm(&circle, radius + 1, 0, radius, radius); image.copy_from(&*part, width - radius, 0).unwrap(); - let part = crop_imm(&mut circle, 0, radius + 1, radius, radius); + let part = crop_imm(&circle, 0, radius + 1, radius, radius); image.copy_from(&*part, 0, height - radius).unwrap(); - let part = crop_imm(&mut circle, radius + 1, radius + 1, radius, radius); + let part = crop_imm(&circle, radius + 1, radius + 1, radius, radius); image .copy_from(&*part, width - radius, height - radius) .unwrap();