mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 09:13:39 +01: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:
parent
cbd96237fd
commit
ed09f90e5e
@ -408,7 +408,7 @@ impl SerializedSyntaxSet {
|
||||
fn deserialize(&self) -> Result<SyntaxSet> {
|
||||
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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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::<Result<Vec<StyleComponent>>>()
|
||||
})
|
||||
.transpose()?;
|
||||
|
@ -25,7 +25,7 @@ pub fn clear_assets() {
|
||||
|
||||
pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<HighlightingAssets> {
|
||||
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<Highlighti
|
||||
}
|
||||
|
||||
let custom_assets = if use_custom_assets {
|
||||
HighlightingAssets::from_cache(&cache_dir).ok()
|
||||
HighlightingAssets::from_cache(cache_dir).ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -226,7 +226,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
|
||||
|
||||
fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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<dyn Printer> = 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,
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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::<Vec<_>>();
|
||||
|
||||
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::<Vec<String>>()
|
||||
|
Loading…
Reference in New Issue
Block a user