From ed09f90e5e3b0b2bed93a591157b8b3a73e07ef8 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 18 Aug 2021 20:37:38 +0200 Subject: Fix all lints that are new with Rust 1.54 They are all of the following type: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow --- src/assets.rs | 2 +- src/bin/bat/app.rs | 2 +- src/bin/bat/assets.rs | 4 ++-- src/bin/bat/main.rs | 2 +- src/controller.rs | 8 ++++---- src/input.rs | 2 +- src/printer.rs | 12 ++++++------ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 71a63bbc..a5f31cef 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -408,7 +408,7 @@ impl SerializedSyntaxSet { fn deserialize(&self) -> Result { match self { SerializedSyntaxSet::FromBinary(data) => Ok(from_binary(data)), - SerializedSyntaxSet::FromFile(ref path) => asset_from_cache(&path, "syntax set"), + SerializedSyntaxSet::FromFile(ref path) => asset_from_cache(path, "syntax set"), } } } diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index f20bd502..bef66070 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -301,7 +301,7 @@ impl App { .map(|style_str| { style_str .split(',') - .map(|x| StyleComponent::from_str(&x)) + .map(|x| StyleComponent::from_str(x)) .collect::>>() }) .transpose()?; diff --git a/src/bin/bat/assets.rs b/src/bin/bat/assets.rs index b50575dd..5e75492f 100644 --- a/src/bin/bat/assets.rs +++ b/src/bin/bat/assets.rs @@ -25,7 +25,7 @@ pub fn clear_assets() { pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result { let cache_dir = PROJECT_DIRS.cache_dir(); - if let Some(metadata) = AssetsMetadata::load_from_folder(&cache_dir)? { + if let Some(metadata) = AssetsMetadata::load_from_folder(cache_dir)? { if !metadata.is_compatible_with(crate_version!()) { return Err(format!( "The binary caches for the user-customized syntaxes and themes \ @@ -42,7 +42,7 @@ pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result Result<()> { fn run_controller(inputs: Vec, config: &Config) -> Result { let assets = assets_from_cache_or_binary(config.use_custom_assets)?; - let controller = Controller::new(&config, &assets); + let controller = Controller::new(config, &assets); controller.run(inputs) } diff --git a/src/controller.rs b/src/controller.rs index a4d88c63..5e74c89e 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -45,7 +45,7 @@ impl<'b> Controller<'b> { // Do not launch the pager if NONE of the input files exist let mut paging_mode = self.config.paging_mode; if self.config.paging_mode != PagingMode::Never { - let call_pager = inputs.iter().any(|ref input| { + let call_pager = inputs.iter().any(|input| { if let InputKind::OrdinaryFile(ref path) = input.kind { Path::new(path).exists() } else { @@ -124,11 +124,11 @@ impl<'b> Controller<'b> { }; let mut printer: Box = if self.config.loop_through { - Box::new(SimplePrinter::new(&self.config)) + Box::new(SimplePrinter::new(self.config)) } else { Box::new(InteractivePrinter::new( - &self.config, - &self.assets, + self.config, + self.assets, &mut opened_input, #[cfg(feature = "git")] &line_changes, diff --git a/src/input.rs b/src/input.rs index 012701ad..786a9e05 100644 --- a/src/input.rs +++ b/src/input.rs @@ -51,7 +51,7 @@ impl InputDescription { pub fn title(&self) -> &String { match self.title.as_ref() { - Some(ref title) => title, + Some(title) => title, None => &self.name, } } diff --git a/src/printer.rs b/src/printer.rs index f07d2db1..0b37cd2e 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -372,19 +372,19 @@ impl<'a> Printer for InteractivePrinter<'a> { line_buffer: &[u8], ) -> Result<()> { let line = if self.config.show_nonprintable { - replace_nonprintable(&line_buffer, self.config.tab_width) + replace_nonprintable(line_buffer, self.config.tab_width) } else { match self.content_type { Some(ContentType::BINARY) | None => { return Ok(()); } Some(ContentType::UTF_16LE) => UTF_16LE - .decode(&line_buffer, DecoderTrap::Replace) + .decode(line_buffer, DecoderTrap::Replace) .map_err(|_| "Invalid UTF-16LE")?, Some(ContentType::UTF_16BE) => UTF_16BE - .decode(&line_buffer, DecoderTrap::Replace) + .decode(line_buffer, DecoderTrap::Replace) .map_err(|_| "Invalid UTF-16BE")?, - _ => String::from_utf8_lossy(&line_buffer).to_string(), + _ => String::from_utf8_lossy(line_buffer).to_string(), } }; @@ -420,7 +420,7 @@ impl<'a> Printer for InteractivePrinter<'a> { let decorations = self .decorations .iter() - .map(|ref d| d.generate(line_number, false, self)) + .map(|d| d.generate(line_number, false, self)) .collect::>(); for deco in decorations { @@ -531,7 +531,7 @@ impl<'a> Printer for InteractivePrinter<'a> { "{} ", self.decorations .iter() - .map(|ref d| d + .map(|d| d .generate(line_number, true, self) .text) .collect::>() -- cgit v1.2.3