on master help sign in
fix some clippy warnings
commit43b2ee5e71f70b8f1f805d2c45331807ef20bafe authorMarcoIeni <11428655+MarcoIeni@users.noreply.github.com> dateThu 5 Nov 2020, 22:29 (6 years ago) parent51463a4
7 files changed+11−25
src/bin/bat/app.rs+3−8 src/bin/bat/config.rs+1−1 src/controller.rs+1−1 src/input.rs+3−8 src/output.rs+1−5 src/pretty_printer.rs+1−1 src/printer.rs+1−1
src/bin/bat/app.rs+3−8
@@ -169,9 +169,7 @@ impl App {
169169 || match self.matches.value_of("color") {
170170 Some("always") => true,
171171 Some("never") => false,
172− Some("auto") | _ => {
173− env::var_os("NO_COLOR").is_none() && self.interactive_output
174− }
172+ _ => env::var_os("NO_COLOR").is_none() && self.interactive_output,
175173 },
176174 paging_mode,
177175 term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
@@ -226,17 +224,14 @@ impl App {
226224 style_components,
227225 syntax_mapping,
228226 pager: self.matches.value_of("pager"),
229− use_italic_text: match self.matches.value_of("italic-text") {
230− Some("always") => true,
231− _ => false,
232− },
227+ use_italic_text: matches!(self.matches.value_of("italic-text"), Some("always")),
233228 highlighted_lines: self
234229 .matches
235230 .values_of("highlight-line")
236231 .map(|ws| ws.map(LineRange::from).collect())
237232 .transpose()?
238233 .map(LineRanges::from)
239− .map(|lr| HighlightedLineRanges(lr))
234+ .map(HighlightedLineRanges)
240235 .unwrap_or_default(),
241236 })
242237 }
src/bin/bat/config.rs+1−1
@@ -85,7 +85,7 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
8585 .ok()
8686 .map(|content| get_args_from_str(&content))
8787 .transpose()?
88− .unwrap_or_else(|| vec![]))
88+ .unwrap_or_else(Vec::new))
8989}
9090
9191pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
src/controller.rs+1−1
@@ -161,7 +161,7 @@ impl<'b> Controller<'b> {
161161 Ok(no_errors)
162162 }
163163
164− fn print_file<'a>(
164+ fn print_file(
165165 &self,
166166 printer: &mut dyn Printer,
167167 writer: &mut dyn Write,
src/input.rs+3−8
@@ -137,17 +137,12 @@ impl<'a> Input<'a> {
137137 }
138138
139139 pub fn is_stdin(&self) -> bool {
140− if let InputKind::StdIn = self.kind {
141− true
142− } else {
143− false
144− }
140+ matches!(self.kind, InputKind::StdIn)
145141 }
146142
147143 pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
148− match provided_name {
149− Some(name) => self.description.name = name.to_string_lossy().to_string(),
150− None => {}
144+ if let Some(name) = provided_name {
145+ self.description.name = name.to_string_lossy().to_string()
151146 }
152147
153148 self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
src/output.rs+1−5
@@ -150,11 +150,7 @@ impl OutputType {
150150
151151 #[cfg(feature = "paging")]
152152 pub(crate) fn is_pager(&self) -> bool {
153− if let OutputType::Pager(_) = self {
154− true
155− } else {
156− false
157− }
153+ matches!(self, OutputType::Pager(_))
158154 }
159155
160156 #[cfg(not(feature = "paging"))]
src/pretty_printer.rs+1−1
@@ -338,7 +338,7 @@ impl<'a> Input<'a> {
338338
339339 /// A new input from bytes.
340340 pub fn from_bytes(bytes: &'a [u8]) -> Self {
341− Input::from_reader(bytes).into()
341+ Input::from_reader(bytes)
342342 }
343343
344344 /// A new input from STDIN.
src/printer.rs+1−1
@@ -311,7 +311,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
311311 description
312312 .kind()
313313 .map(|kind| format!("{}: ", kind))
314− .unwrap_or("".into()),
314+ .unwrap_or_else(|| "".into()),
315315 self.colors.filename.paint(description.title()),
316316 mode
317317 )?;