clippy lint: avoid manual implementation of Option

This commit is contained in:
auronandace 2021-08-22 08:08:11 +01:00 committed by Abin Simon
parent 74fbb96e68
commit e738de7b8c
7 changed files with 12 additions and 35 deletions

View file

@ -84,11 +84,8 @@ impl Configurable<Self> 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<Self> {

View file

@ -29,11 +29,8 @@ impl Configurable<Self> 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<Self> {
if let Some(deref) = &config.dereference {
Some(Self(*deref))
} else {
None
}
config.dereference.as_ref()
.map(|deref| Self(*deref))
}
}

View file

@ -30,11 +30,8 @@ impl Configurable<Self> 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<Self> {
if let Some(ind) = &config.indicators {
Some(Self(*ind))
} else {
None
}
config.indicators.as_ref()
.map(|ind| Self(*ind))
}
}

View file

@ -21,11 +21,8 @@ impl Configurable<Self> for SymlinkArrow {
/// returns its value as the value of the `SymlinkArrow`, in a [Some].
/// Otherwise this returns [None].
fn from_config(config: &Config) -> Option<Self> {
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()))
}
}

View file

@ -30,11 +30,7 @@ impl Configurable<Self> for NoSymlink {
/// this returns it as the value of the `NoSymlink`, in a [Some].
/// Otherwise this returns [None].
fn from_config(config: &Config) -> Option<Self> {
if let Some(no_link) = config.no_symlink {
Some(Self(no_link))
} else {
None
}
config.no_symlink.map(Self)
}
}

View file

@ -30,11 +30,7 @@ impl Configurable<Self> for TotalSize {
/// this returns it as the value of the `TotalSize`, in a [Some].
/// Otherwise this returns [None].
fn from_config(config: &Config) -> Option<Self> {
if let Some(total) = config.total_size {
Some(Self(total))
} else {
None
}
config.total_size.map(Self)
}
}

View file

@ -45,11 +45,8 @@ impl<'a> From<&'a Path> for SymLink {
impl SymLink {
pub fn symlink_string(&self) -> Option<String> {
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 {