diff --git a/Cargo.toml b/Cargo.toml index 7c44e64d3..e7b20eb74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -666,7 +666,6 @@ should_panic_without_expect = "allow" # 2 doc_markdown = "allow" unused_self = "allow" -map_unwrap_or = "allow" enum_glob_use = "allow" ptr_cast_constness = "allow" borrow_as_ptr = "allow" diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 650ec1348..c1df9ed13 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -2319,8 +2319,7 @@ fn copy_file( let initial_dest_metadata = dest.symlink_metadata().ok(); let dest_is_symlink = initial_dest_metadata .as_ref() - .map(|md| md.file_type().is_symlink()) - .unwrap_or(false); + .is_some_and(|md| md.file_type().is_symlink()); let dest_target_exists = dest.try_exists().unwrap_or(false); // Fail if dest is a dangling symlink or a symlink this program created previously if dest_is_symlink { diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index a2ddbed6a..2eb979331 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -443,7 +443,7 @@ fn process_utf8_line(line: &str, ctx: &mut FoldContext<'_, W>) -> URes } } - let next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); + let next_idx = iter.peek().map_or(line_bytes.len(), |(idx, _)| *idx); if ch == '\n' { *ctx.last_space = None; diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index e66da6b6e..7abfcde8c 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -479,8 +479,7 @@ fn extract_sort(options: &clap::ArgMatches) -> Sort { let sort_index = options .get_one::(options::SORT) .and_then(|_| options.indices_of(options::SORT)) - .map(|mut indices| indices.next_back().unwrap_or(0)) - .unwrap_or(0); + .map_or(0, |mut indices| indices.next_back().unwrap_or(0)); let time_index = get_last_index(options::sort::TIME); let size_index = get_last_index(options::sort::SIZE); let none_index = get_last_index(options::sort::NONE); @@ -599,8 +598,7 @@ fn extract_color(options: &clap::ArgMatches) -> bool { let color_index = options .get_one::(options::COLOR) .and_then(|_| options.indices_of(options::COLOR)) - .map(|mut indices| indices.next_back().unwrap_or(0)) - .unwrap_or(0); + .map_or(0, |mut indices| indices.next_back().unwrap_or(0)); let unsorted_all_index = get_last_index(options::files::UNSORTED_ALL); let color_enabled = match options.get_one::(options::COLOR) { diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index fae2942f0..9af3d80ca 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -240,8 +240,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { use std::os::unix::process::ExitStatusExt; let signal_msg = status .signal() - .map(|s| s.to_string()) - .unwrap_or_else(|| "unknown".to_string()); + .map_or_else(|| "unknown".to_string(), |s| s.to_string()); Err(USimpleError::new( 1, translate!("stdbuf-error-killed-by-signal", "signal" => signal_msg), diff --git a/src/uucore/src/lib/mods/locale.rs b/src/uucore/src/lib/mods/locale.rs index 559dc72ef..cd2a54343 100644 --- a/src/uucore/src/lib/mods/locale.rs +++ b/src/uucore/src/lib/mods/locale.rs @@ -264,8 +264,7 @@ fn create_english_bundle_from_embedded( fn get_message_internal(id: &str, args: Option) -> String { LOCALIZER.with(|lock| { lock.get() - .map(|loc| loc.format(id, args.as_ref())) - .unwrap_or_else(|| id.to_string()) // Return the key ID if localizer not initialized + .map_or_else(|| id.to_string(), |loc| loc.format(id, args.as_ref())) // Return the key ID if localizer not initialized }) }