on master help sign in
Fix clippy warnings
commite2ac6de7832c4de491e12e9c7d7c5725191cc2db authorsharkdp <davidpeter@web.de> dateThu 10 May 2018, 12:50 (8 years ago) parent25cee00
3 files changed+12−21
src/assets.rs+7−16 src/main.rs+4−4 src/printer.rs+1−1
src/assets.rs+7−16
@@ -57,10 +57,7 @@ impl HighlightingAssets {
5757 )
5858 })?;
5959 let mut syntax_set: SyntaxSet = from_reader(syntax_set_file).map_err(|_| {
60− io::Error::new(
61− io::ErrorKind::Other,
62− format!("Could not parse cached syntax set"),
63− )
60+ io::Error::new(io::ErrorKind::Other, "Could not parse cached syntax set")
6461 })?;
6562 syntax_set.link_syntaxes();
6663
@@ -70,12 +67,8 @@ impl HighlightingAssets {
7067 theme_set_path.to_string_lossy()
7168 )
7269 })?;
73− let theme_set: ThemeSet = from_reader(theme_set_file).map_err(|_| {
74− io::Error::new(
75− io::ErrorKind::Other,
76− format!("Could not parse cached theme set"),
77− )
78− })?;
70+ let theme_set: ThemeSet = from_reader(theme_set_file)
71+ .map_err(|_| io::Error::new(io::ErrorKind::Other, "Could not parse cached theme set"))?;
7972
8073 Ok(HighlightingAssets {
8174 syntax_set,
@@ -134,12 +127,10 @@ impl HighlightingAssets {
134127 }
135128
136129 pub fn default_theme(&self) -> Result<&Theme> {
137− Ok(self.theme_set.themes.get("Default").ok_or_else(|| {
138− io::Error::new(
139− io::ErrorKind::Other,
140− format!("Could not find 'Default' theme"),
141− )
142− })?)
130+ Ok(self.theme_set
131+ .themes
132+ .get("Default")
133+ .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Could not find 'Default' theme"))?)
143134 }
144135}
145136
src/main.rs+4−4
@@ -22,7 +22,7 @@ mod diff;
2222mod printer;
2323mod terminal;
2424
25−use std::collections::{HashMap, HashSet};
25+use std::collections::HashSet;
2626use std::env;
2727use std::fs::{self, File};
2828use std::io::{self, BufRead, BufReader, Write};
@@ -257,7 +257,7 @@ fn print_file(
257257 break;
258258 }
259259 Ok(_) => {
260− if !line_buffer.ends_with("\n") {
260+ if !line_buffer.ends_with('\n') {
261261 line_buffer.push('\n');
262262 }
263263 &line_buffer
@@ -459,14 +459,14 @@ fn run() -> Result<()> {
459459
460460 let longest = languages
461461 .iter()
462− .filter(|s| !s.hidden && s.file_extensions.len() > 0)
462+ .filter(|s| !s.hidden && !s.file_extensions.is_empty())
463463 .map(|s| s.name.len())
464464 .max()
465465 .unwrap_or(32); // Fallback width if they have no language definitions.
466466
467467 let separator = " ";
468468 for lang in languages {
469− if lang.hidden || lang.file_extensions.len() == 0 {
469+ if lang.hidden || lang.file_extensions.is_empty() {
470470 continue;
471471 }
472472 print!("{:width$}{}", lang.name, separator, width = longest);
src/printer.rs+1−1
@@ -92,7 +92,7 @@ impl<'a> Printer<'a> {
9292 decorations
9393 .into_iter()
9494 .filter_map(|dec| if grid_requested {
95− Some(dec.unwrap_or(" ".to_owned()))
95+ Some(dec.unwrap_or_else(|| " ".to_owned()))
9696 } else {
9797 dec
9898 })