mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 22:22:26 +00:00
clippy lint: avoid manual implementation of Option
This commit is contained in:
parent
74fbb96e68
commit
e738de7b8c
7 changed files with 12 additions and 35 deletions
|
@ -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> {
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue