Skip to content

Commit 2000af8

Browse files

File tree

6 files changed

+6
-12
lines changed

6 files changed

+6
-12
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ should_panic_without_expect = "allow" # 2
666666

667667
doc_markdown = "allow"
668668
unused_self = "allow"
669-
map_unwrap_or = "allow"
670669
enum_glob_use = "allow"
671670
ptr_cast_constness = "allow"
672671
borrow_as_ptr = "allow"

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,8 +2319,7 @@ fn copy_file(
23192319
let initial_dest_metadata = dest.symlink_metadata().ok();
23202320
let dest_is_symlink = initial_dest_metadata
23212321
.as_ref()
2322-
.map(|md| md.file_type().is_symlink())
2323-
.unwrap_or(false);
2322+
.is_some_and(|md| md.file_type().is_symlink());
23242323
let dest_target_exists = dest.try_exists().unwrap_or(false);
23252324
// Fail if dest is a dangling symlink or a symlink this program created previously
23262325
if dest_is_symlink {

src/uu/fold/src/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fn process_utf8_line<W: Write>(line: &str, ctx: &mut FoldContext<'_, W>) -> URes
443443
}
444444
}
445445

446-
let next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len());
446+
let next_idx = iter.peek().map_or(line_bytes.len(), |(idx, _)| *idx);
447447

448448
if ch == '\n' {
449449
*ctx.last_space = None;

src/uu/ls/src/ls.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@ fn extract_sort(options: &clap::ArgMatches) -> Sort {
479479
let sort_index = options
480480
.get_one::<String>(options::SORT)
481481
.and_then(|_| options.indices_of(options::SORT))
482-
.map(|mut indices| indices.next_back().unwrap_or(0))
483-
.unwrap_or(0);
482+
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
484483
let time_index = get_last_index(options::sort::TIME);
485484
let size_index = get_last_index(options::sort::SIZE);
486485
let none_index = get_last_index(options::sort::NONE);
@@ -599,8 +598,7 @@ fn extract_color(options: &clap::ArgMatches) -> bool {
599598
let color_index = options
600599
.get_one::<String>(options::COLOR)
601600
.and_then(|_| options.indices_of(options::COLOR))
602-
.map(|mut indices| indices.next_back().unwrap_or(0))
603-
.unwrap_or(0);
601+
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
604602
let unsorted_all_index = get_last_index(options::files::UNSORTED_ALL);
605603

606604
let color_enabled = match options.get_one::<String>(options::COLOR) {

src/uu/stdbuf/src/stdbuf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
240240
use std::os::unix::process::ExitStatusExt;
241241
let signal_msg = status
242242
.signal()
243-
.map(|s| s.to_string())
244-
.unwrap_or_else(|| "unknown".to_string());
243+
.map_or_else(|| "unknown".to_string(), |s| s.to_string());
245244
Err(USimpleError::new(
246245
1,
247246
translate!("stdbuf-error-killed-by-signal", "signal" => signal_msg),

src/uucore/src/lib/mods/locale.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ fn create_english_bundle_from_embedded(
264264
fn get_message_internal(id: &str, args: Option<FluentArgs>) -> String {
265265
LOCALIZER.with(|lock| {
266266
lock.get()
267-
.map(|loc| loc.format(id, args.as_ref()))
268-
.unwrap_or_else(|| id.to_string()) // Return the key ID if localizer not initialized
267+
.map_or_else(|| id.to_string(), |loc| loc.format(id, args.as_ref())) // Return the key ID if localizer not initialized
269268
})
270269
}
271270

0 commit comments

Comments
 (0)