mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +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 {
|
fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||||
if name == suffix {
|
if name == suffix {
|
||||||
name.to_owned()
|
return name.to_owned();
|
||||||
} else {
|
|
||||||
name.strip_suffix(suffix).unwrap_or(name).to_owned()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name.ends_with(suffix) {
|
||||||
|
return name[..name.len() - suffix.len()].to_owned();
|
||||||
|
}
|
||||||
|
|
||||||
|
name.to_owned()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue