1//! Utilities to help with buffering.
2
3#![allow(unsafe_code)]
4
5use core::mem::MaybeUninit;
6use core::slice;
7
8/// Split an uninitialized byte slice into initialized and uninitialized parts.
9///
10/// # Safety
11///
12/// At least `init` bytes must be initialized.
13#[inline]
14pub(super) unsafe fn split_init(
15 buf: &mut [MaybeUninit<u8>],
16 init: usize,
17) -> (&mut [u8], &mut [MaybeUninit<u8>]) {
18 let (init, uninit) = buf.split_at_mut(init);
19 let init = slice::from_raw_parts_mut(init.as_mut_ptr() as *mut u8, init.len());
20 (init, uninit)
21}
22