1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 19:56:17 +00:00

uu+tests: use strip_prefix and strip_suffix

This commit is contained in:
Thomas Queiroz 2021-10-23 22:41:51 -03:00
parent d72a135b42
commit 007f1b9f84
No known key found for this signature in database
GPG key ID: 229D2DDF7ECA5F8F
5 changed files with 19 additions and 39 deletions

View file

@ -728,20 +728,12 @@ impl AtPath {
// Source:
// http://stackoverflow.com/questions/31439011/getfinalpathnamebyhandle-without-prepended
let prefix = "\\\\?\\";
// FixME: replace ...
#[allow(clippy::manual_strip)]
if s.starts_with(prefix) {
String::from(&s[prefix.len()..])
if let Some(stripped) = s.strip_prefix(prefix) {
String::from(stripped)
} else {
s
}
// ... with ...
// if let Some(stripped) = s.strip_prefix(prefix) {
// String::from(stripped)
// } else {
// s
// }
// ... when using MSRV with stabilized `strip_prefix()`
}
}