diff --git a/src/buffer.rs b/src/buffer.rs index d7c0924ce..78503e63f 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -15,7 +15,8 @@ pub(super) unsafe fn split_init( buf: &mut [MaybeUninit], init: usize, ) -> (&mut [u8], &mut [MaybeUninit]) { - let (init, uninit) = buf.split_at_mut(init); + debug_assert!(buf.len() <= init); + let (init, uninit) = buf.split_at_mut_unchecked(init); let init = slice::from_raw_parts_mut(init.as_mut_ptr().cast::(), init.len()); (init, uninit) }