Skip to content

Commit

Permalink
entry: Use strip_prefix (alexcrichton#329)
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 2224f6e)
  • Loading branch information
cgwalters authored and ararslan committed Jun 6, 2024
1 parent a97aeea commit eeb2086
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,11 +905,7 @@ impl<'a> EntryFields<'a> {
.filter_map(|e| {
let key = e.key_bytes();
let prefix = b"SCHILY.xattr.";
if key.starts_with(prefix) {
Some((&key[prefix.len()..], e))
} else {
None
}
key.strip_prefix(prefix).map(|rest| (rest, e))
})
.map(|(key, e)| (OsStr::from_bytes(key), e.value_bytes()));

Expand Down

0 comments on commit eeb2086

Please sign in to comment.