Skip to content

Commit dfc3119

Browse files
committed
refactor(rm): simplify preserve_root_all assignment using map_or
Replace map().unwrap_or(false) with map_or(false, ...) for more concise and idiomatic code in the rm uumain function. This change maintains the same logic while reducing redundancy.
1 parent 1525f6a commit dfc3119

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/uu/rm/src/rm.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
256256
preserve_root: !matches.get_flag(OPT_NO_PRESERVE_ROOT),
257257
preserve_root_all: matches
258258
.get_many::<String>(OPT_PRESERVE_ROOT)
259-
.map(|values| values.into_iter().any(|v| v == "all"))
260-
.unwrap_or(false),
259+
.map_or(false, |values| values.any(|v| v == "all")),
261260
recursive: matches.get_flag(OPT_RECURSIVE),
262261
dir: matches.get_flag(OPT_DIR),
263262
verbose: matches.get_flag(OPT_VERBOSE),

0 commit comments

Comments
 (0)