Skip to content

Commit 2224f6e

Browse files
authored
entry: Use strip_prefix (#329)
Minor drive by code cleanup; `strip_prefix` is just more readable and more bug-resistant than manually doing it with `starts_with` combined with slicing.
1 parent a37c9b6 commit 2224f6e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/entry.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,7 @@ impl<'a> EntryFields<'a> {
865865
.filter_map(|e| {
866866
let key = e.key_bytes();
867867
let prefix = b"SCHILY.xattr.";
868-
if key.starts_with(prefix) {
869-
Some((&key[prefix.len()..], e))
870-
} else {
871-
None
872-
}
868+
key.strip_prefix(prefix).map(|rest| (rest, e))
873869
})
874870
.map(|(key, e)| (OsStr::from_bytes(key), e.value_bytes()));
875871

0 commit comments

Comments
 (0)