From f49b051b903961c26b2a8ce4b74a9146f63c8050 Mon Sep 17 00:00:00 2001 From: philomathic_life <15947783+zacknewman@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:09:56 +0000 Subject: [PATCH 1/3] Clarify ReadBuf::uninit allows initialized buffers as well --- tokio/src/io/read_buf.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/io/read_buf.rs b/tokio/src/io/read_buf.rs index ec53ea7a207..2644a53db91 100644 --- a/tokio/src/io/read_buf.rs +++ b/tokio/src/io/read_buf.rs @@ -39,7 +39,7 @@ impl<'a> ReadBuf<'a> { } } - /// Creates a new `ReadBuf` from a fully uninitialized buffer. + /// Creates a new `ReadBuf` from a buffer that may be fully uninitialized. /// /// Use `assume_init` if part of the buffer is known to be already initialized. #[inline] From 35816c6e1bc150253eaf4dad7baaeb1bf3e27c78 Mon Sep 17 00:00:00 2001 From: philomathic_life <15947783+zacknewman@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:34:04 +0000 Subject: [PATCH 2/3] Remove fully Co-authored-by: Alice Ryhl --- tokio/src/io/read_buf.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/io/read_buf.rs b/tokio/src/io/read_buf.rs index 2644a53db91..1492f6d1588 100644 --- a/tokio/src/io/read_buf.rs +++ b/tokio/src/io/read_buf.rs @@ -39,7 +39,7 @@ impl<'a> ReadBuf<'a> { } } - /// Creates a new `ReadBuf` from a buffer that may be fully uninitialized. + /// 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. #[inline] From e91f224b40f615dbc9e1b90f27606091785ad773 Mon Sep 17 00:00:00 2001 From: philomathic_life <15947783+zacknewman@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:44:24 +0000 Subject: [PATCH 3/3] Expand what `ReadBuf::uninit` does internally --- tokio/src/io/read_buf.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tokio/src/io/read_buf.rs b/tokio/src/io/read_buf.rs index 1492f6d1588..edef84851ec 100644 --- a/tokio/src/io/read_buf.rs +++ b/tokio/src/io/read_buf.rs @@ -41,7 +41,9 @@ impl<'a> ReadBuf<'a> { /// 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]) -> ReadBuf<'a> { ReadBuf {