Skip to content

Commit 3443ca5

Browse files
authored
docs: clarify the behavior of Buf::chunk (#717)
1 parent 8cc9407 commit 3443ca5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/buf/buf_impl.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ pub trait Buf {
141141
///
142142
/// # Implementer notes
143143
///
144-
/// This function should never panic. Once the end of the buffer is reached,
145-
/// i.e., `Buf::remaining` returns 0, calls to `chunk()` should return an
146-
/// empty slice.
144+
/// This function should never panic. `chunk()` should return an empty
145+
/// slice **if and only if** `remaining()` returns 0. In other words,
146+
/// `chunk()` returning an empty slice implies that `remaining()` will
147+
/// return 0 and `remaining()` returning 0 implies that `chunk()` will
148+
/// return an empty slice.
147149
// The `chunk` method was previously called `bytes`. This alias makes the rename
148150
// more easily discoverable.
149151
#[cfg_attr(docsrs, doc(alias = "bytes"))]

src/buf/buf_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub unsafe trait BufMut {
165165
///
166166
/// # Implementer notes
167167
///
168-
/// This function should never panic. `chunk_mut` should return an empty
168+
/// This function should never panic. `chunk_mut()` should return an empty
169169
/// slice **if and only if** `remaining_mut()` returns 0. In other words,
170170
/// `chunk_mut()` returning an empty slice implies that `remaining_mut()` will
171171
/// return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will

0 commit comments

Comments
 (0)