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

Merge pull request #2726 from thomasqueirozb/strip_pre_suffix

uu+tests: use strip_prefix and strip_suffix
This commit is contained in:
Michael Debertol 2021-11-01 23:34:27 +01:00 committed by GitHub
commit 7c94bb082e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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()`
}
}