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

docs: clarify the behavior of Buf::chunk #717

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
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
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