mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-22 04:48:48 +00:00
Fix clippy warnings
This commit is contained in:
parent
25cee002f9
commit
e2ac6de783
@ -57,10 +57,7 @@ impl HighlightingAssets {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
let mut syntax_set: SyntaxSet = from_reader(syntax_set_file).map_err(|_| {
|
let mut syntax_set: SyntaxSet = from_reader(syntax_set_file).map_err(|_| {
|
||||||
io::Error::new(
|
io::Error::new(io::ErrorKind::Other, "Could not parse cached syntax set")
|
||||||
io::ErrorKind::Other,
|
|
||||||
format!("Could not parse cached syntax set"),
|
|
||||||
)
|
|
||||||
})?;
|
})?;
|
||||||
syntax_set.link_syntaxes();
|
syntax_set.link_syntaxes();
|
||||||
|
|
||||||
@ -70,12 +67,8 @@ impl HighlightingAssets {
|
|||||||
theme_set_path.to_string_lossy()
|
theme_set_path.to_string_lossy()
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
let theme_set: ThemeSet = from_reader(theme_set_file).map_err(|_| {
|
let theme_set: ThemeSet = from_reader(theme_set_file)
|
||||||
io::Error::new(
|
.map_err(|_| io::Error::new(io::ErrorKind::Other, "Could not parse cached theme set"))?;
|
||||||
io::ErrorKind::Other,
|
|
||||||
format!("Could not parse cached theme set"),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(HighlightingAssets {
|
Ok(HighlightingAssets {
|
||||||
syntax_set,
|
syntax_set,
|
||||||
@ -134,12 +127,10 @@ impl HighlightingAssets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_theme(&self) -> Result<&Theme> {
|
pub fn default_theme(&self) -> Result<&Theme> {
|
||||||
Ok(self.theme_set.themes.get("Default").ok_or_else(|| {
|
Ok(self.theme_set
|
||||||
io::Error::new(
|
.themes
|
||||||
io::ErrorKind::Other,
|
.get("Default")
|
||||||
format!("Could not find 'Default' theme"),
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Could not find 'Default' theme"))?)
|
||||||
)
|
|
||||||
})?)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ mod diff;
|
|||||||
mod printer;
|
mod printer;
|
||||||
mod terminal;
|
mod terminal;
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, BufRead, BufReader, Write};
|
use std::io::{self, BufRead, BufReader, Write};
|
||||||
@ -257,7 +257,7 @@ fn print_file(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if !line_buffer.ends_with("\n") {
|
if !line_buffer.ends_with('\n') {
|
||||||
line_buffer.push('\n');
|
line_buffer.push('\n');
|
||||||
}
|
}
|
||||||
&line_buffer
|
&line_buffer
|
||||||
@ -459,14 +459,14 @@ fn run() -> Result<()> {
|
|||||||
|
|
||||||
let longest = languages
|
let longest = languages
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|s| !s.hidden && s.file_extensions.len() > 0)
|
.filter(|s| !s.hidden && !s.file_extensions.is_empty())
|
||||||
.map(|s| s.name.len())
|
.map(|s| s.name.len())
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(32); // Fallback width if they have no language definitions.
|
.unwrap_or(32); // Fallback width if they have no language definitions.
|
||||||
|
|
||||||
let separator = " ";
|
let separator = " ";
|
||||||
for lang in languages {
|
for lang in languages {
|
||||||
if lang.hidden || lang.file_extensions.len() == 0 {
|
if lang.hidden || lang.file_extensions.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
print!("{:width$}{}", lang.name, separator, width = longest);
|
print!("{:width$}{}", lang.name, separator, width = longest);
|
||||||
|
@ -92,7 +92,7 @@ impl<'a> Printer<'a> {
|
|||||||
decorations
|
decorations
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|dec| if grid_requested {
|
.filter_map(|dec| if grid_requested {
|
||||||
Some(dec.unwrap_or(" ".to_owned()))
|
Some(dec.unwrap_or_else(|| " ".to_owned()))
|
||||||
} else {
|
} else {
|
||||||
dec
|
dec
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user