Skip to content

Commit

Permalink
♻️ use &[T]::split_at_checked
Browse files Browse the repository at this point in the history
`&[T]::split_at_checked` was stabilized on rust 1.80
  • Loading branch information
ChanTsune committed Jul 26, 2024
1 parent 4dfa407 commit 5235cf1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/entry/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ impl ExtendedAttribute {
.split_first_chunk::<{ mem::size_of::<u32>() }>()
.ok_or(io::ErrorKind::UnexpectedEof)?;
let len = u32::from_be_bytes(*len) as usize;
// TODO: use split_at_checked instead
let (name, value) = value.split_at(len);
let (name, value) = value
.split_at_checked(len)
.ok_or(io::ErrorKind::UnexpectedEof)?;
let name = String::from_utf8(name.to_vec()).map_err(|_| io::ErrorKind::InvalidData)?;

let (len, value) = value
Expand Down

0 comments on commit 5235cf1

Please sign in to comment.