mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
clippy: fix clippy warnings
See: https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
This commit is contained in:
parent
55ffdb0847
commit
beb56b10ab
8 changed files with 10 additions and 10 deletions
|
@ -727,7 +727,7 @@ fn get_root_dev_ino() -> Result<DeviceAndINode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_dev_ino_check(root_dev_ino: Option<DeviceAndINode>, dir_dev_ino: DeviceAndINode) -> bool {
|
fn root_dev_ino_check(root_dev_ino: Option<DeviceAndINode>, dir_dev_ino: DeviceAndINode) -> bool {
|
||||||
root_dev_ino.map_or(false, |root_dev_ino| root_dev_ino == dir_dev_ino)
|
root_dev_ino == Some(dir_dev_ino)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_dev_ino_warn(dir_name: &Path) {
|
fn root_dev_ino_warn(dir_name: &Path) {
|
||||||
|
|
|
@ -533,7 +533,7 @@ impl StatPrinter {
|
||||||
|
|
||||||
if !self
|
if !self
|
||||||
.threshold
|
.threshold
|
||||||
.map_or(false, |threshold| threshold.should_exclude(size))
|
.is_some_and(|threshold| threshold.should_exclude(size))
|
||||||
&& self
|
&& self
|
||||||
.max_depth
|
.max_depth
|
||||||
.map_or(true, |max_depth| stat_info.depth <= max_depth)
|
.map_or(true, |max_depth| stat_info.depth <= max_depth)
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub fn uu_app() -> Command {
|
||||||
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
||||||
for (i, arg) in args.iter().enumerate() {
|
for (i, arg) in args.iter().enumerate() {
|
||||||
let slice = &arg;
|
let slice = &arg;
|
||||||
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_ascii_digit()) {
|
if slice.starts_with('-') && slice.chars().nth(1).is_some_and(|c| c.is_ascii_digit()) {
|
||||||
let mut v = args.to_vec();
|
let mut v = args.to_vec();
|
||||||
v.remove(i);
|
v.remove(i);
|
||||||
return (v, Some(slice[1..].to_owned()));
|
return (v, Some(slice[1..].to_owned()));
|
||||||
|
|
|
@ -336,11 +336,11 @@ impl Settings {
|
||||||
let blocking_stdin = self.pid == 0
|
let blocking_stdin = self.pid == 0
|
||||||
&& self.follow == Some(FollowMode::Descriptor)
|
&& self.follow == Some(FollowMode::Descriptor)
|
||||||
&& self.num_inputs() == 1
|
&& self.num_inputs() == 1
|
||||||
&& Handle::stdin().map_or(false, |handle| {
|
&& Handle::stdin().is_ok_and(|handle| {
|
||||||
handle
|
handle
|
||||||
.as_file()
|
.as_file()
|
||||||
.metadata()
|
.metadata()
|
||||||
.map_or(false, |meta| !meta.is_file())
|
.is_ok_and(|meta| !meta.is_file())
|
||||||
});
|
});
|
||||||
|
|
||||||
if !blocking_stdin && std::io::stdin().is_terminal() {
|
if !blocking_stdin && std::io::stdin().is_terminal() {
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl Input {
|
||||||
pub fn is_tailable(&self) -> bool {
|
pub fn is_tailable(&self) -> bool {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
InputKind::File(path) => path_is_tailable(path),
|
InputKind::File(path) => path_is_tailable(path),
|
||||||
InputKind::Stdin => self.resolve().map_or(false, |path| path_is_tailable(&path)),
|
InputKind::Stdin => self.resolve().is_some_and(|path| path_is_tailable(&path)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ impl PathExtTail for Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path_is_tailable(path: &Path) -> bool {
|
pub fn path_is_tailable(path: &Path) -> bool {
|
||||||
path.is_file() || path.exists() && path.metadata().map_or(false, |meta| meta.is_tailable())
|
path.is_file() || path.exists() && path.metadata().is_ok_and(|meta| meta.is_tailable())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -383,7 +383,7 @@ fn should_extract_obs_skip_chars(
|
||||||
&& posix_version().is_some_and(|v| v <= OBSOLETE)
|
&& posix_version().is_some_and(|v| v <= OBSOLETE)
|
||||||
&& !preceding_long_opt_req_value
|
&& !preceding_long_opt_req_value
|
||||||
&& !preceding_short_opt_req_value
|
&& !preceding_short_opt_req_value
|
||||||
&& slice.chars().nth(1).map_or(false, |c| c.is_ascii_digit())
|
&& slice.chars().nth(1).is_some_and(|c| c.is_ascii_digit())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to [`filter_args`]
|
/// Helper function to [`filter_args`]
|
||||||
|
|
|
@ -710,7 +710,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
|
||||||
path.as_os_str()
|
path.as_os_str()
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.last()
|
.last()
|
||||||
.map_or(false, |&byte| byte == b'/' || byte == b'\\')
|
.is_some_and(|&byte| byte == b'/' || byte == b'\\')
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn parse_usage(content: &str) -> String {
|
||||||
pub fn parse_section(section: &str, content: &str) -> Option<String> {
|
pub fn parse_section(section: &str, content: &str) -> Option<String> {
|
||||||
fn is_section_header(line: &str, section: &str) -> bool {
|
fn is_section_header(line: &str, section: &str) -> bool {
|
||||||
line.strip_prefix("##")
|
line.strip_prefix("##")
|
||||||
.map_or(false, |l| l.trim().to_lowercase() == section)
|
.is_some_and(|l| l.trim().to_lowercase() == section)
|
||||||
}
|
}
|
||||||
|
|
||||||
let section = §ion.to_lowercase();
|
let section = §ion.to_lowercase();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue