diff --git a/src/flags/color.rs b/src/flags/color.rs index da18243..f3b97c0 100644 --- a/src/flags/color.rs +++ b/src/flags/color.rs @@ -84,11 +84,8 @@ impl Configurable for ColorOption { return Some(Self::Never); } - if let Some(color) = &config.color { - Some(color.when) - } else { - None - } + config.color.as_ref() + .map(|color| color.when) } fn from_environment() -> Option { diff --git a/src/flags/dereference.rs b/src/flags/dereference.rs index 47877c4..9a045d1 100644 --- a/src/flags/dereference.rs +++ b/src/flags/dereference.rs @@ -29,11 +29,8 @@ impl Configurable for Dereference { /// If the `Config::dereference` has value, this returns its value /// as the value of the `Dereference`, in a [Some], Otherwise this returns [None]. fn from_config(config: &Config) -> Option { - if let Some(deref) = &config.dereference { - Some(Self(*deref)) - } else { - None - } + config.dereference.as_ref() + .map(|deref| Self(*deref)) } } diff --git a/src/flags/indicators.rs b/src/flags/indicators.rs index 5b68ebb..f42817d 100644 --- a/src/flags/indicators.rs +++ b/src/flags/indicators.rs @@ -30,11 +30,8 @@ impl Configurable for Indicators { /// this returns its value as the value of the `Indicators`, in a [Some]. /// Otherwise this returns [None]. fn from_config(config: &Config) -> Option { - if let Some(ind) = &config.indicators { - Some(Self(*ind)) - } else { - None - } + config.indicators.as_ref() + .map(|ind| Self(*ind)) } } diff --git a/src/flags/symlink_arrow.rs b/src/flags/symlink_arrow.rs index fab36b4..2381a54 100644 --- a/src/flags/symlink_arrow.rs +++ b/src/flags/symlink_arrow.rs @@ -21,11 +21,8 @@ impl Configurable for SymlinkArrow { /// returns its value as the value of the `SymlinkArrow`, in a [Some]. /// Otherwise this returns [None]. fn from_config(config: &Config) -> Option { - if let Some(arrow) = &config.symlink_arrow { - Some(SymlinkArrow(arrow.to_string())) - } else { - None - } + config.symlink_arrow.as_ref() + .map(|arrow| SymlinkArrow(arrow.to_string())) } } diff --git a/src/flags/symlinks.rs b/src/flags/symlinks.rs index cc340c5..c2960a8 100644 --- a/src/flags/symlinks.rs +++ b/src/flags/symlinks.rs @@ -30,11 +30,7 @@ impl Configurable for NoSymlink { /// this returns it as the value of the `NoSymlink`, in a [Some]. /// Otherwise this returns [None]. fn from_config(config: &Config) -> Option { - if let Some(no_link) = config.no_symlink { - Some(Self(no_link)) - } else { - None - } + config.no_symlink.map(Self) } } diff --git a/src/flags/total_size.rs b/src/flags/total_size.rs index c2dc2e8..3b5ab6f 100644 --- a/src/flags/total_size.rs +++ b/src/flags/total_size.rs @@ -30,11 +30,7 @@ impl Configurable for TotalSize { /// this returns it as the value of the `TotalSize`, in a [Some]. /// Otherwise this returns [None]. fn from_config(config: &Config) -> Option { - if let Some(total) = config.total_size { - Some(Self(total)) - } else { - None - } + config.total_size.map(Self) } } diff --git a/src/meta/symlink.rs b/src/meta/symlink.rs index d5048a8..2fcb6ab 100644 --- a/src/meta/symlink.rs +++ b/src/meta/symlink.rs @@ -45,11 +45,8 @@ impl<'a> From<&'a Path> for SymLink { impl SymLink { pub fn symlink_string(&self) -> Option { - if let Some(ref target) = self.target { - Some(target.to_string()) - } else { - None - } + self.target.as_ref() + .map(|target| target.to_string()) } pub fn render(&self, colors: &Colors, flag: &Flags) -> ColoredString {