mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 00:51:56 +00:00 
			
		
		
		
	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
This commit is contained in:
		@@ -408,7 +408,7 @@ impl SerializedSyntaxSet {
 | 
				
			|||||||
    fn deserialize(&self) -> Result<SyntaxSet> {
 | 
					    fn deserialize(&self) -> Result<SyntaxSet> {
 | 
				
			||||||
        match self {
 | 
					        match self {
 | 
				
			||||||
            SerializedSyntaxSet::FromBinary(data) => Ok(from_binary(data)),
 | 
					            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"),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -301,7 +301,7 @@ impl App {
 | 
				
			|||||||
                    .map(|style_str| {
 | 
					                    .map(|style_str| {
 | 
				
			||||||
                        style_str
 | 
					                        style_str
 | 
				
			||||||
                            .split(',')
 | 
					                            .split(',')
 | 
				
			||||||
                            .map(|x| StyleComponent::from_str(&x))
 | 
					                            .map(|x| StyleComponent::from_str(x))
 | 
				
			||||||
                            .collect::<Result<Vec<StyleComponent>>>()
 | 
					                            .collect::<Result<Vec<StyleComponent>>>()
 | 
				
			||||||
                    })
 | 
					                    })
 | 
				
			||||||
                    .transpose()?;
 | 
					                    .transpose()?;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ pub fn clear_assets() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<HighlightingAssets> {
 | 
					pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<HighlightingAssets> {
 | 
				
			||||||
    let cache_dir = PROJECT_DIRS.cache_dir();
 | 
					    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!()) {
 | 
					        if !metadata.is_compatible_with(crate_version!()) {
 | 
				
			||||||
            return Err(format!(
 | 
					            return Err(format!(
 | 
				
			||||||
                "The binary caches for the user-customized syntaxes and themes \
 | 
					                "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<Highlighti
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let custom_assets = if use_custom_assets {
 | 
					    let custom_assets = if use_custom_assets {
 | 
				
			||||||
        HighlightingAssets::from_cache(&cache_dir).ok()
 | 
					        HighlightingAssets::from_cache(cache_dir).ok()
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        None
 | 
					        None
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -226,7 +226,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
 | 
					fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
 | 
				
			||||||
    let assets = assets_from_cache_or_binary(config.use_custom_assets)?;
 | 
					    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)
 | 
					    controller.run(inputs)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,7 @@ impl<'b> Controller<'b> {
 | 
				
			|||||||
            // Do not launch the pager if NONE of the input files exist
 | 
					            // Do not launch the pager if NONE of the input files exist
 | 
				
			||||||
            let mut paging_mode = self.config.paging_mode;
 | 
					            let mut paging_mode = self.config.paging_mode;
 | 
				
			||||||
            if self.config.paging_mode != PagingMode::Never {
 | 
					            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 {
 | 
					                    if let InputKind::OrdinaryFile(ref path) = input.kind {
 | 
				
			||||||
                        Path::new(path).exists()
 | 
					                        Path::new(path).exists()
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
@@ -124,11 +124,11 @@ impl<'b> Controller<'b> {
 | 
				
			|||||||
                    };
 | 
					                    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    let mut printer: Box<dyn Printer> = if self.config.loop_through {
 | 
					                    let mut printer: Box<dyn Printer> = if self.config.loop_through {
 | 
				
			||||||
                        Box::new(SimplePrinter::new(&self.config))
 | 
					                        Box::new(SimplePrinter::new(self.config))
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        Box::new(InteractivePrinter::new(
 | 
					                        Box::new(InteractivePrinter::new(
 | 
				
			||||||
                            &self.config,
 | 
					                            self.config,
 | 
				
			||||||
                            &self.assets,
 | 
					                            self.assets,
 | 
				
			||||||
                            &mut opened_input,
 | 
					                            &mut opened_input,
 | 
				
			||||||
                            #[cfg(feature = "git")]
 | 
					                            #[cfg(feature = "git")]
 | 
				
			||||||
                            &line_changes,
 | 
					                            &line_changes,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,7 +51,7 @@ impl InputDescription {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    pub fn title(&self) -> &String {
 | 
					    pub fn title(&self) -> &String {
 | 
				
			||||||
        match self.title.as_ref() {
 | 
					        match self.title.as_ref() {
 | 
				
			||||||
            Some(ref title) => title,
 | 
					            Some(title) => title,
 | 
				
			||||||
            None => &self.name,
 | 
					            None => &self.name,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -372,19 +372,19 @@ impl<'a> Printer for InteractivePrinter<'a> {
 | 
				
			|||||||
        line_buffer: &[u8],
 | 
					        line_buffer: &[u8],
 | 
				
			||||||
    ) -> Result<()> {
 | 
					    ) -> Result<()> {
 | 
				
			||||||
        let line = if self.config.show_nonprintable {
 | 
					        let line = if self.config.show_nonprintable {
 | 
				
			||||||
            replace_nonprintable(&line_buffer, self.config.tab_width)
 | 
					            replace_nonprintable(line_buffer, self.config.tab_width)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            match self.content_type {
 | 
					            match self.content_type {
 | 
				
			||||||
                Some(ContentType::BINARY) | None => {
 | 
					                Some(ContentType::BINARY) | None => {
 | 
				
			||||||
                    return Ok(());
 | 
					                    return Ok(());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                Some(ContentType::UTF_16LE) => UTF_16LE
 | 
					                Some(ContentType::UTF_16LE) => UTF_16LE
 | 
				
			||||||
                    .decode(&line_buffer, DecoderTrap::Replace)
 | 
					                    .decode(line_buffer, DecoderTrap::Replace)
 | 
				
			||||||
                    .map_err(|_| "Invalid UTF-16LE")?,
 | 
					                    .map_err(|_| "Invalid UTF-16LE")?,
 | 
				
			||||||
                Some(ContentType::UTF_16BE) => UTF_16BE
 | 
					                Some(ContentType::UTF_16BE) => UTF_16BE
 | 
				
			||||||
                    .decode(&line_buffer, DecoderTrap::Replace)
 | 
					                    .decode(line_buffer, DecoderTrap::Replace)
 | 
				
			||||||
                    .map_err(|_| "Invalid UTF-16BE")?,
 | 
					                    .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
 | 
					            let decorations = self
 | 
				
			||||||
                .decorations
 | 
					                .decorations
 | 
				
			||||||
                .iter()
 | 
					                .iter()
 | 
				
			||||||
                .map(|ref d| d.generate(line_number, false, self))
 | 
					                .map(|d| d.generate(line_number, false, self))
 | 
				
			||||||
                .collect::<Vec<_>>();
 | 
					                .collect::<Vec<_>>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for deco in decorations {
 | 
					            for deco in decorations {
 | 
				
			||||||
@@ -531,7 +531,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
 | 
				
			|||||||
                                                "{} ",
 | 
					                                                "{} ",
 | 
				
			||||||
                                                self.decorations
 | 
					                                                self.decorations
 | 
				
			||||||
                                                    .iter()
 | 
					                                                    .iter()
 | 
				
			||||||
                                                    .map(|ref d| d
 | 
					                                                    .map(|d| d
 | 
				
			||||||
                                                        .generate(line_number, true, self)
 | 
					                                                        .generate(line_number, true, self)
 | 
				
			||||||
                                                        .text)
 | 
					                                                        .text)
 | 
				
			||||||
                                                    .collect::<Vec<String>>()
 | 
					                                                    .collect::<Vec<String>>()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user