Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Jan 22, 2025
1 parent 3c69e50 commit 2b7f5b2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ semicolon_if_nothing_returned = "warn"
single_char_pattern = "warn"
explicit_iter_loop = "warn"
if_not_else = "warn"
manual_if_else = "warn"

all = { level = "deny", priority = -1 }
cargo = { level = "warn", priority = -1 }
Expand Down
19 changes: 8 additions & 11 deletions src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,13 @@ fn basename(fullname: &str, suffix: &str) -> String {

// Convert to path buffer and get last path component
let pb = PathBuf::from(path);
match pb.components().last() {
Some(c) => {
let name = c.as_os_str().to_str().unwrap();
if name == suffix {
name.to_string()
} else {
name.strip_suffix(suffix).unwrap_or(name).to_string()
}
}

None => String::new(),
}
pb.components().next_back().map_or_else(String::new, |c| {
let name = c.as_os_str().to_str().unwrap();
if name == suffix {
name.to_string()
} else {
name.strip_suffix(suffix).unwrap_or(name).to_string()
}
})
}
2 changes: 1 addition & 1 deletion src/uu/df/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn is_over_mounted(mounts: &[MountInfo], mount: &MountInfo) -> bool {
let last_mount_for_dir = mounts
.iter()
.filter(|m| m.mount_dir == mount.mount_dir)
.last();
.next_back();

if let Some(lmi) = last_mount_for_dir {
lmi.dev_name != mount.dev_name
Expand Down
2 changes: 1 addition & 1 deletion src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR
}

let mut targetpath = target_dir.to_path_buf();
let filename = sourcepath.components().last().unwrap();
let filename = sourcepath.components().next_back().unwrap();
targetpath.push(filename);

show_if_err!(copy(sourcepath, &targetpath, b));
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ mod tests_split_iterator {
| '*' | '?' | '[' | '#' | '˜' | '=' | '%' => {
special = true;
}
_ => continue,
_ => (),
}
}

Expand Down

0 comments on commit 2b7f5b2

Please sign in to comment.