mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
strip_suffix is not avaialble with rust 1.40
This commit is contained in:
parent
d67560c37a
commit
d219b6e705
1 changed files with 7 additions and 3 deletions
|
@ -113,8 +113,12 @@ fn basename(fullname: &str, suffix: &str) -> String {
|
|||
|
||||
fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||
if name == suffix {
|
||||
return name.to_owned();
|
||||
}
|
||||
|
||||
if name.ends_with(suffix) {
|
||||
return name[..name.len() - suffix.len()].to_owned();
|
||||
}
|
||||
|
||||
name.to_owned()
|
||||
} else {
|
||||
name.strip_suffix(suffix).unwrap_or(name).to_owned()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue