fix some clippy warnings

This commit is contained in:
MarcoIeni 2020-11-05 22:29:04 +01:00 committed by David Peter
parent 51463a4b41
commit 43b2ee5e71
7 changed files with 11 additions and 25 deletions

View File

@ -169,9 +169,7 @@ impl App {
|| match self.matches.value_of("color") {
Some("always") => true,
Some("never") => false,
Some("auto") | _ => {
env::var_os("NO_COLOR").is_none() && self.interactive_output
}
_ => env::var_os("NO_COLOR").is_none() && self.interactive_output,
},
paging_mode,
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
@ -226,17 +224,14 @@ impl App {
style_components,
syntax_mapping,
pager: self.matches.value_of("pager"),
use_italic_text: match self.matches.value_of("italic-text") {
Some("always") => true,
_ => false,
},
use_italic_text: matches!(self.matches.value_of("italic-text"), Some("always")),
highlighted_lines: self
.matches
.values_of("highlight-line")
.map(|ws| ws.map(LineRange::from).collect())
.transpose()?
.map(LineRanges::from)
.map(|lr| HighlightedLineRanges(lr))
.map(HighlightedLineRanges)
.unwrap_or_default(),
})
}

View File

@ -85,7 +85,7 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
.ok()
.map(|content| get_args_from_str(&content))
.transpose()?
.unwrap_or_else(|| vec![]))
.unwrap_or_else(Vec::new))
}
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {

View File

@ -161,7 +161,7 @@ impl<'b> Controller<'b> {
Ok(no_errors)
}
fn print_file<'a>(
fn print_file(
&self,
printer: &mut dyn Printer,
writer: &mut dyn Write,

View File

@ -137,17 +137,12 @@ impl<'a> Input<'a> {
}
pub fn is_stdin(&self) -> bool {
if let InputKind::StdIn = self.kind {
true
} else {
false
}
matches!(self.kind, InputKind::StdIn)
}
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
match provided_name {
Some(name) => self.description.name = name.to_string_lossy().to_string(),
None => {}
if let Some(name) = provided_name {
self.description.name = name.to_string_lossy().to_string()
}
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());

View File

@ -150,11 +150,7 @@ impl OutputType {
#[cfg(feature = "paging")]
pub(crate) fn is_pager(&self) -> bool {
if let OutputType::Pager(_) = self {
true
} else {
false
}
matches!(self, OutputType::Pager(_))
}
#[cfg(not(feature = "paging"))]

View File

@ -338,7 +338,7 @@ impl<'a> Input<'a> {
/// A new input from bytes.
pub fn from_bytes(bytes: &'a [u8]) -> Self {
Input::from_reader(bytes).into()
Input::from_reader(bytes)
}
/// A new input from STDIN.

View File

@ -311,7 +311,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
description
.kind()
.map(|kind| format!("{}: ", kind))
.unwrap_or("".into()),
.unwrap_or_else(|| "".into()),
self.colors.filename.paint(description.title()),
mode
)?;