mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
clippy: fix map_unwrap_or lint
https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
This commit is contained in:
committed by
Daniel Hofstetter
parent
5b54e084bb
commit
0626a4d103
@@ -20,9 +20,7 @@ pub fn is_unsafe_overwrite<I: AsHandleRef, O: AsHandleRef>(input: &I, output: &O
|
||||
}
|
||||
|
||||
// Check if the output file is empty
|
||||
FileInformation::from_file(output)
|
||||
.map(|info| info.file_size() > 0)
|
||||
.unwrap_or(false)
|
||||
FileInformation::from_file(output).is_ok_and(|info| info.file_size() > 0)
|
||||
}
|
||||
|
||||
/// Get the file path for a file handle
|
||||
|
||||
+1
-3
@@ -350,9 +350,7 @@ fn embed_locale_file(
|
||||
/// Check if we are cross-compiling for WASI (build.rs runs on the host,
|
||||
/// so `#[cfg(target_os = "wasi")]` does not work here).
|
||||
fn is_wasi_target() -> bool {
|
||||
env::var("CARGO_CFG_TARGET_OS")
|
||||
.map(|os| os == "wasi")
|
||||
.unwrap_or(false)
|
||||
env::var("CARGO_CFG_TARGET_OS").is_ok_and(|os| os == "wasi")
|
||||
}
|
||||
|
||||
/// For WASI/WASM builds, embed ALL available .ftl files in a locale
|
||||
|
||||
@@ -67,9 +67,7 @@ pub fn splice_exact(source: &impl AsFd, target: &impl AsFd, len: usize) -> std::
|
||||
#[inline]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub fn might_fuse(source: &impl AsFd) -> bool {
|
||||
rustix::fs::fstatfs(source)
|
||||
.map(|stats| stats.f_type == 0x6573_5546) // FUSE magic number, too many platform specific clippy warning with const
|
||||
.unwrap_or(true)
|
||||
rustix::fs::fstatfs(source).map_or(true, |stats| stats.f_type == 0x6573_5546) // FUSE magic number, too many platform specific clippy warning with const
|
||||
}
|
||||
|
||||
/// Return verified /dev/null
|
||||
|
||||
@@ -1054,8 +1054,7 @@ fn test_nonexistent_file() {
|
||||
fn test_df_all_shows_binfmt_misc() {
|
||||
// Check if binfmt_misc is mounted
|
||||
let is_mounted = std::fs::read_to_string("/proc/self/mountinfo")
|
||||
.map(|content| content.lines().any(|line| line.contains("binfmt_misc")))
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|content| content.lines().any(|line| line.contains("binfmt_misc")));
|
||||
|
||||
if is_mounted {
|
||||
let output = new_ucmd!()
|
||||
@@ -1076,8 +1075,7 @@ fn test_df_all_shows_binfmt_misc() {
|
||||
fn test_df_hides_binfmt_misc_by_default() {
|
||||
// Check if binfmt_misc is mounted
|
||||
let is_mounted = std::fs::read_to_string("/proc/self/mountinfo")
|
||||
.map(|content| content.lines().any(|line| line.contains("binfmt_misc")))
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|content| content.lines().any(|line| line.contains("binfmt_misc")));
|
||||
|
||||
if is_mounted {
|
||||
let output = new_ucmd!()
|
||||
|
||||
@@ -109,8 +109,7 @@ pub fn is_locale_available(locale: &str) -> bool {
|
||||
.env("LC_ALL", locale)
|
||||
.arg("charmap")
|
||||
.output()
|
||||
.map(|o| String::from_utf8_lossy(&o.stdout).trim() == "UTF-8")
|
||||
.unwrap_or(false)
|
||||
.is_ok_and(|o| String::from_utf8_lossy(&o.stdout).trim() == "UTF-8")
|
||||
}
|
||||
|
||||
/// Read a test scenario fixture, returning its bytes
|
||||
|
||||
Reference in New Issue
Block a user