Skip to content

Commit 02eb2c0

Browse files
authored
Merge pull request #6910 from sylvestre/clippy1
clippy: fix clippy warnings
2 parents 33c65d5 + 7708f6e commit 02eb2c0

File tree

10 files changed

+12
-12
lines changed

10 files changed

+12
-12
lines changed

src/uu/chcon/src/chcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ fn get_root_dev_ino() -> Result<DeviceAndINode> {
727727
}
728728

729729
fn root_dev_ino_check(root_dev_ino: Option<DeviceAndINode>, dir_dev_ino: DeviceAndINode) -> bool {
730-
root_dev_ino.map_or(false, |root_dev_ino| root_dev_ino == dir_dev_ino)
730+
root_dev_ino == Some(dir_dev_ino)
731731
}
732732

733733
fn root_dev_ino_warn(dir_name: &Path) {

src/uu/du/src/du.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ impl StatPrinter {
533533

534534
if !self
535535
.threshold
536-
.map_or(false, |threshold| threshold.should_exclude(size))
536+
.is_some_and(|threshold| threshold.should_exclude(size))
537537
&& self
538538
.max_depth
539539
.map_or(true, |max_depth| stat_info.depth <= max_depth)

src/uu/fold/src/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn uu_app() -> Command {
9999
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
100100
for (i, arg) in args.iter().enumerate() {
101101
let slice = &arg;
102-
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_ascii_digit()) {
102+
if slice.starts_with('-') && slice.chars().nth(1).is_some_and(|c| c.is_ascii_digit()) {
103103
let mut v = args.to_vec();
104104
v.remove(i);
105105
return (v, Some(slice[1..].to_owned()));

src/uu/split/src/split.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl Settings {
492492
}
493493
match first.as_str() {
494494
"\\0" => b'\0',
495-
s if s.as_bytes().len() == 1 => s.as_bytes()[0],
495+
s if s.len() == 1 => s.as_bytes()[0],
496496
s => return Err(SettingsError::MultiCharacterSeparator(s.to_string())),
497497
}
498498
}

src/uu/tac/src/tac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn buffer_tac(data: &[u8], before: bool, separator: &str) -> std::io::Result<()>
184184
let mut out = BufWriter::new(out.lock());
185185

186186
// The number of bytes in the line separator.
187-
let slen = separator.as_bytes().len();
187+
let slen = separator.len();
188188

189189
// The index of the start of the next line in the `data`.
190190
//

src/uu/tail/src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ impl Settings {
336336
let blocking_stdin = self.pid == 0
337337
&& self.follow == Some(FollowMode::Descriptor)
338338
&& self.num_inputs() == 1
339-
&& Handle::stdin().map_or(false, |handle| {
339+
&& Handle::stdin().is_ok_and(|handle| {
340340
handle
341341
.as_file()
342342
.metadata()
343-
.map_or(false, |meta| !meta.is_file())
343+
.is_ok_and(|meta| !meta.is_file())
344344
});
345345

346346
if !blocking_stdin && std::io::stdin().is_terminal() {

src/uu/tail/src/paths.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Input {
9393
pub fn is_tailable(&self) -> bool {
9494
match &self.kind {
9595
InputKind::File(path) => path_is_tailable(path),
96-
InputKind::Stdin => self.resolve().map_or(false, |path| path_is_tailable(&path)),
96+
InputKind::Stdin => self.resolve().is_some_and(|path| path_is_tailable(&path)),
9797
}
9898
}
9999
}
@@ -233,7 +233,7 @@ impl PathExtTail for Path {
233233
}
234234

235235
pub fn path_is_tailable(path: &Path) -> bool {
236-
path.is_file() || path.exists() && path.metadata().map_or(false, |meta| meta.is_tailable())
236+
path.is_file() || path.exists() && path.metadata().is_ok_and(|meta| meta.is_tailable())
237237
}
238238

239239
#[inline]

src/uu/uniq/src/uniq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ fn should_extract_obs_skip_chars(
383383
&& posix_version().is_some_and(|v| v <= OBSOLETE)
384384
&& !preceding_long_opt_req_value
385385
&& !preceding_short_opt_req_value
386-
&& slice.chars().nth(1).map_or(false, |c| c.is_ascii_digit())
386+
&& slice.chars().nth(1).is_some_and(|c| c.is_ascii_digit())
387387
}
388388

389389
/// Helper function to [`filter_args`]

src/uucore/src/lib/features/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
710710
path.as_os_str()
711711
.as_bytes()
712712
.last()
713-
.map_or(false, |&byte| byte == b'/' || byte == b'\\')
713+
.is_some_and(|&byte| byte == b'/' || byte == b'\\')
714714
}
715715

716716
#[cfg(windows)]

src/uuhelp_parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn parse_usage(content: &str) -> String {
7373
pub fn parse_section(section: &str, content: &str) -> Option<String> {
7474
fn is_section_header(line: &str, section: &str) -> bool {
7575
line.strip_prefix("##")
76-
.map_or(false, |l| l.trim().to_lowercase() == section)
76+
.is_some_and(|l| l.trim().to_lowercase() == section)
7777
}
7878

7979
let section = &section.to_lowercase();

0 commit comments

Comments
 (0)