diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 95638c30bb4..c4ca73c6742 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -244,13 +244,13 @@ fn parse_delimiters(delimiters: &OsString) -> UResult]>> { } match bytes[i] { b'0' => vec.push(Box::new([])), - b'\\' => vec.push(Box::new([b'\\'])), - b'n' => vec.push(Box::new([b'\n'])), - b't' => vec.push(Box::new([b'\t'])), - b'b' => vec.push(Box::new([b'\x08'])), - b'f' => vec.push(Box::new([b'\x0C'])), - b'r' => vec.push(Box::new([b'\r'])), - b'v' => vec.push(Box::new([b'\x0B'])), + b'\\' => vec.push(Box::new(*b"\\")), + b'n' => vec.push(Box::new(*b"\n")), + b't' => vec.push(Box::new(*b"\t")), + b'b' => vec.push(Box::new(*b"\x08")), + b'f' => vec.push(Box::new(*b"\x0C")), + b'r' => vec.push(Box::new(*b"\r")), + b'v' => vec.push(Box::new(*b"\x0B")), _ => { // Unknown escape: strip backslash, use the following character(s) let remaining = &bytes[i..]; diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 7d5c6bdc71a..d382a999387 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -63,12 +63,12 @@ const PATTERNS: [Pattern; 22] = [ Pattern::Single(b'\xFF'), Pattern::Single(b'\x55'), Pattern::Single(b'\xAA'), - Pattern::Multi([b'\x24', b'\x92', b'\x49']), - Pattern::Multi([b'\x49', b'\x24', b'\x92']), - Pattern::Multi([b'\x6D', b'\xB6', b'\xDB']), - Pattern::Multi([b'\x92', b'\x49', b'\x24']), - Pattern::Multi([b'\xB6', b'\xDB', b'\x6D']), - Pattern::Multi([b'\xDB', b'\x6D', b'\xB6']), + Pattern::Multi(*b"\x24\x92\x49"), + Pattern::Multi(*b"\x49\x24\x92"), + Pattern::Multi(*b"\x6D\xB6\xDB"), + Pattern::Multi(*b"\x92\x49\x24"), + Pattern::Multi(*b"\xB6\xDB\x6D"), + Pattern::Multi(*b"\xDB\x6D\xB6"), Pattern::Single(b'\x11'), Pattern::Single(b'\x22'), Pattern::Single(b'\x33'), diff --git a/src/uu/tail/src/parse.rs b/src/uu/tail/src/parse.rs index 846ba49b8d3..a95999a5ec2 100644 --- a/src/uu/tail/src/parse.rs +++ b/src/uu/tail/src/parse.rs @@ -38,11 +38,10 @@ pub fn parse_obsolete(src: &OsString) -> Option let sign = if let Some(r) = rest.strip_prefix('-') { rest = r; '-' - } else if let Some(r) = rest.strip_prefix('+') { + } else { + let r = rest.strip_prefix('+')?; rest = r; '+' - } else { - return None; }; let end_num = rest diff --git a/src/uucore/src/lib/features/format/num_format.rs b/src/uucore/src/lib/features/format/num_format.rs index a99d7f5f840..b275401ece7 100644 --- a/src/uucore/src/lib/features/format/num_format.rs +++ b/src/uucore/src/lib/features/format/num_format.rs @@ -413,7 +413,7 @@ fn bd_to_string_exp_with_prec(bd: &BigDecimal, precision: usize) -> (String, i64 // In the unlikely case we had an overflow, correct for that. if digits.len() == precision + 1 { - debug_assert!(&digits[precision..] == "0"); + debug_assert_eq!(&digits[precision..], "0"); digits.truncate(precision); p -= 1; } diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index b94959c405b..d39e41deeec 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -235,8 +235,8 @@ fn is_root(path: &Path, would_traverse_symlink: bool) -> bool { // which we need to avoid here. // All directory-ish paths match "*/", except ".", "..", "*/.", and "*/..". let path_bytes = path.as_os_str().as_encoded_bytes(); - let looks_like_dir = path_bytes == [b'.'] - || path_bytes == [b'.', b'.'] + let looks_like_dir = path_bytes == *b"." + || path_bytes == *b".." || path_bytes.ends_with(&[MAIN_SEPARATOR as u8]) || path_bytes.ends_with(&[MAIN_SEPARATOR as u8, b'.']) || path_bytes.ends_with(&[MAIN_SEPARATOR as u8, b'.', b'.']);