io: clarify ReadBuf::uninit allows initialized buffers as well (#7053)

This commit is contained in:
philomathic_life 2025-01-06 10:16:15 +00:00 committed by GitHub
parent a1520f5525
commit 463502cbaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,9 +39,11 @@ impl<'a> ReadBuf<'a> {
}
}
/// Creates a new `ReadBuf` from a fully uninitialized buffer.
/// Creates a new `ReadBuf` from a buffer that may be uninitialized.
///
/// Use `assume_init` if part of the buffer is known to be already initialized.
/// The internal cursor will mark the entire buffer as uninitialized. If
/// the buffer is known to be partially initialized, then use `assume_init`
/// to move the internal cursor.
#[inline]
pub fn uninit(buf: &'a mut [MaybeUninit<u8>]) -> ReadBuf<'a> {
ReadBuf {