1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #6910 from sylvestre/clippy1

clippy: fix clippy warnings
This commit is contained in:
Daniel Hofstetter 2024-12-18 08:08:56 +01:00 committed by GitHub
commit 02eb2c0bab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 12 additions and 12 deletions

View file

@ -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) {

View file

@ -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)

View file

@ -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()));

View file

@ -492,7 +492,7 @@ impl Settings {
} }
match first.as_str() { match first.as_str() {
"\\0" => b'\0', "\\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())), s => return Err(SettingsError::MultiCharacterSeparator(s.to_string())),
} }
} }

View file

@ -184,7 +184,7 @@ fn buffer_tac(data: &[u8], before: bool, separator: &str) -> std::io::Result<()>
let mut out = BufWriter::new(out.lock()); let mut out = BufWriter::new(out.lock());
// The number of bytes in the line separator. // 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`. // The index of the start of the next line in the `data`.
// //

View file

@ -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() {

View file

@ -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]

View file

@ -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`]

View file

@ -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)]

View file

@ -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 = &section.to_lowercase(); let section = &section.to_lowercase();