Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed May 21, 2020
1 parent 9b75f1a commit 190e68f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tokio/src/io/util/read_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,9 @@ fn reserve<R: AsyncRead + ?Sized>(buf: &mut Vec<u8>, read: &R, bytes: usize) {
fn get_unused_capacity(buf: &mut Vec<u8>) -> &mut [MaybeUninit<u8>] {
let prepare_from = buf.len();
let prepare_len = buf.capacity() - prepare_from;
// safety: prepare_from is the length of a vector, so it can't overflow isize,
// and the pointer will stay inside the allocation.
let ptr = unsafe {
buf.as_mut_ptr()
.offset(prepare_from as isize)
.cast::<MaybeUninit<u8>>()
};
// safety: prepare_from is the length of the vector, so it will stay inside the
// allocation.
let ptr = unsafe { buf.as_mut_ptr().add(prepare_from).cast::<MaybeUninit<u8>>() };

// safety: The memory is properly allocated due to the invariants provided by
// Vec<u8>, and since the item type is MaybeUninit<u8>, it is safe for the
Expand Down

0 comments on commit 190e68f

Please sign in to comment.