mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 06:02:36 +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);
|
return Some(Self::Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(color) = &config.color {
|
config.color.as_ref()
|
||||||
Some(color.when)
|
.map(|color| color.when)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_environment() -> Option<Self> {
|
fn from_environment() -> Option<Self> {
|
||||||
|
|
|
@ -29,11 +29,8 @@ impl Configurable<Self> for Dereference {
|
||||||
/// If the `Config::dereference` has value, this returns its value
|
/// If the `Config::dereference` has value, this returns its value
|
||||||
/// as the value of the `Dereference`, in a [Some], Otherwise this returns [None].
|
/// as the value of the `Dereference`, in a [Some], Otherwise this returns [None].
|
||||||
fn from_config(config: &Config) -> Option<Self> {
|
fn from_config(config: &Config) -> Option<Self> {
|
||||||
if let Some(deref) = &config.dereference {
|
config.dereference.as_ref()
|
||||||
Some(Self(*deref))
|
.map(|deref| Self(*deref))
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,8 @@ impl Configurable<Self> for Indicators {
|
||||||
/// this returns its value as the value of the `Indicators`, in a [Some].
|
/// this returns its value as the value of the `Indicators`, in a [Some].
|
||||||
/// Otherwise this returns [None].
|
/// Otherwise this returns [None].
|
||||||
fn from_config(config: &Config) -> Option<Self> {
|
fn from_config(config: &Config) -> Option<Self> {
|
||||||
if let Some(ind) = &config.indicators {
|
config.indicators.as_ref()
|
||||||
Some(Self(*ind))
|
.map(|ind| Self(*ind))
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,8 @@ impl Configurable<Self> for SymlinkArrow {
|
||||||
/// returns its value as the value of the `SymlinkArrow`, in a [Some].
|
/// returns its value as the value of the `SymlinkArrow`, in a [Some].
|
||||||
/// Otherwise this returns [None].
|
/// Otherwise this returns [None].
|
||||||
fn from_config(config: &Config) -> Option<Self> {
|
fn from_config(config: &Config) -> Option<Self> {
|
||||||
if let Some(arrow) = &config.symlink_arrow {
|
config.symlink_arrow.as_ref()
|
||||||
Some(SymlinkArrow(arrow.to_string()))
|
.map(|arrow| SymlinkArrow(arrow.to_string()))
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,7 @@ impl Configurable<Self> for NoSymlink {
|
||||||
/// this returns it as the value of the `NoSymlink`, in a [Some].
|
/// this returns it as the value of the `NoSymlink`, in a [Some].
|
||||||
/// Otherwise this returns [None].
|
/// Otherwise this returns [None].
|
||||||
fn from_config(config: &Config) -> Option<Self> {
|
fn from_config(config: &Config) -> Option<Self> {
|
||||||
if let Some(no_link) = config.no_symlink {
|
config.no_symlink.map(Self)
|
||||||
Some(Self(no_link))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,7 @@ impl Configurable<Self> for TotalSize {
|
||||||
/// this returns it as the value of the `TotalSize`, in a [Some].
|
/// this returns it as the value of the `TotalSize`, in a [Some].
|
||||||
/// Otherwise this returns [None].
|
/// Otherwise this returns [None].
|
||||||
fn from_config(config: &Config) -> Option<Self> {
|
fn from_config(config: &Config) -> Option<Self> {
|
||||||
if let Some(total) = config.total_size {
|
config.total_size.map(Self)
|
||||||
Some(Self(total))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,8 @@ impl<'a> From<&'a Path> for SymLink {
|
||||||
|
|
||||||
impl SymLink {
|
impl SymLink {
|
||||||
pub fn symlink_string(&self) -> Option<String> {
|
pub fn symlink_string(&self) -> Option<String> {
|
||||||
if let Some(ref target) = self.target {
|
self.target.as_ref()
|
||||||
Some(target.to_string())
|
.map(|target| target.to_string())
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&self, colors: &Colors, flag: &Flags) -> ColoredString {
|
pub fn render(&self, colors: &Colors, flag: &Flags) -> ColoredString {
|
||||||
|
|
Loading…
Reference in a new issue