Skip to content

Commit

Permalink
docs: clarify the behavior of Buf::chunk (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvviiv authored Jul 9, 2024
1 parent 8cc9407 commit 3443ca5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/buf/buf_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ pub trait Buf {
///
/// # Implementer notes
///
/// This function should never panic. Once the end of the buffer is reached,
/// i.e., `Buf::remaining` returns 0, calls to `chunk()` should return an
/// empty slice.
/// This function should never panic. `chunk()` should return an empty
/// slice **if and only if** `remaining()` returns 0. In other words,
/// `chunk()` returning an empty slice implies that `remaining()` will
/// return 0 and `remaining()` returning 0 implies that `chunk()` will
/// return an empty slice.
// The `chunk` method was previously called `bytes`. This alias makes the rename
// more easily discoverable.
#[cfg_attr(docsrs, doc(alias = "bytes"))]
Expand Down
2 changes: 1 addition & 1 deletion src/buf/buf_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub unsafe trait BufMut {
///
/// # Implementer notes
///
/// This function should never panic. `chunk_mut` should return an empty
/// This function should never panic. `chunk_mut()` should return an empty
/// slice **if and only if** `remaining_mut()` returns 0. In other words,
/// `chunk_mut()` returning an empty slice implies that `remaining_mut()` will
/// return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will
Expand Down

0 comments on commit 3443ca5

Please sign in to comment.