Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/chcon/src/chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl StatPrinter {

if !self
.threshold
.map_or(false, |threshold| threshold.should_exclude(size))
.is_some_and(|threshold| threshold.should_exclude(size))
&& self
.max_depth
.map_or(true, |max_depth| stat_info.depth <= max_depth)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/fold/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn uu_app() -> Command {
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
for (i, arg) in args.iter().enumerate() {
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();
v.remove(i);
return (v, Some(slice[1..].to_owned()));
Expand Down
2 changes: 1 addition & 1 deletion src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl Settings {
}
match first.as_str() {
"\\0" => b'\0',
s if s.as_bytes().len() == 1 => s.as_bytes()[0],
s if s.len() == 1 => s.as_bytes()[0],
s => return Err(SettingsError::MultiCharacterSeparator(s.to_string())),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tac/src/tac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn buffer_tac(data: &[u8], before: bool, separator: &str) -> std::io::Result<()>
let mut out = BufWriter::new(out.lock());

// The number of bytes in the line separator.
let slen = separator.as_bytes().len();
let slen = separator.len();

// The index of the start of the next line in the `data`.
//
Expand Down
4 changes: 2 additions & 2 deletions src/uu/tail/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ impl Settings {
let blocking_stdin = self.pid == 0
&& self.follow == Some(FollowMode::Descriptor)
&& self.num_inputs() == 1
&& Handle::stdin().map_or(false, |handle| {
&& Handle::stdin().is_ok_and(|handle| {
handle
.as_file()
.metadata()
.map_or(false, |meta| !meta.is_file())
.is_ok_and(|meta| !meta.is_file())
});

if !blocking_stdin && std::io::stdin().is_terminal() {
Expand Down
4 changes: 2 additions & 2 deletions src/uu/tail/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Input {
pub fn is_tailable(&self) -> bool {
match &self.kind {
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)),
}
}
}
Expand Down Expand Up @@ -233,7 +233,7 @@ impl PathExtTail for Path {
}

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]
Expand Down
2 changes: 1 addition & 1 deletion src/uu/uniq/src/uniq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ fn should_extract_obs_skip_chars(
&& posix_version().is_some_and(|v| v <= OBSOLETE)
&& !preceding_long_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`]
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
path.as_os_str()
.as_bytes()
.last()
.map_or(false, |&byte| byte == b'/' || byte == b'\\')
.is_some_and(|&byte| byte == b'/' || byte == b'\\')
}

#[cfg(windows)]
Expand Down
2 changes: 1 addition & 1 deletion src/uuhelp_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn parse_usage(content: &str) -> String {
pub fn parse_section(section: &str, content: &str) -> Option<String> {
fn is_section_header(line: &str, section: &str) -> bool {
line.strip_prefix("##")
.map_or(false, |l| l.trim().to_lowercase() == section)
.is_some_and(|l| l.trim().to_lowercase() == section)
}

let section = &section.to_lowercase();
Expand Down
Loading