Skip to content

Commit

Permalink
Fix clippy hints
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Dec 3, 2018
1 parent 9259dc3 commit 0b0cfe5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/filetypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl FileTypes {
let code = Self::get_code(filetype);
let result = mapping.insert(code, category.clone());

if !result.is_none() {
if result.is_some() {
return Err(VividError::DuplicateFileType(filetype.to_string()));
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn run() -> Result<()> {
let theme_name_env = env::var("VIVID_THEME").ok();
let theme_name = sub_matches
.value_of("theme")
.or(theme_name_env.as_ref().map(String::as_str))
.or_else(|| theme_name_env.as_ref().map(String::as_str))
.unwrap_or("molokai");
let theme_file = format!("{}.yml", theme_name);

Expand All @@ -105,7 +105,7 @@ fn run() -> Result<()> {
theme_path_system.push(theme_file);

let theme_path = util::get_first_existing_path(&[&theme_path_user, &theme_path_system])
.ok_or(VividError::CouldNotFindTheme(theme_name.to_string()))?;
.ok_or_else(|| VividError::CouldNotFindTheme(theme_name.to_string()))?;
let theme = Theme::from_file(theme_path, color_mode)?;

let mut filetypes_list = filetypes.mapping.keys().collect::<Vec<_>>();
Expand Down
6 changes: 3 additions & 3 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ impl Theme {
fn get_color(&self, color_str: &str) -> Result<Color> {
self.colors
.get(color_str)
.map(|c| c.clone())
.or(Color::from_hex_str(color_str).ok())
.ok_or(VividError::UnknownColor(color_str.to_string()))
.cloned()
.or_else(|| Color::from_hex_str(color_str).ok())
.ok_or_else(|| VividError::UnknownColor(color_str.to_string()))
}

pub fn get_style(&self, category: CategoryRef) -> Result<String> {
Expand Down

0 comments on commit 0b0cfe5

Please sign in to comment.