Skip to content

Commit

Permalink
entry: Use strip_prefix (#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.
  • Loading branch information
cgwalters authored Jun 4, 2024
1 parent a37c9b6 commit 2224f6e
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 @@ -865,11 +865,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 2224f6e

Please sign in to comment.