Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify ReadBuf::uninit allows initialized buffers as well #7053

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tokio/src/io/read_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading