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

This commit is contained in:
vvvviiv
2024-07-09 14:13:09 +02:00
committed by GitHub
parent 8cc940779f
commit 3443ca5a0b
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -141,9 +141,11 @@ pub trait Buf {
/// ///
/// # Implementer notes /// # Implementer notes
/// ///
/// This function should never panic. Once the end of the buffer is reached, /// This function should never panic. `chunk()` should return an empty
/// i.e., `Buf::remaining` returns 0, calls to `chunk()` should return an /// slice **if and only if** `remaining()` returns 0. In other words,
/// empty slice. /// `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 // The `chunk` method was previously called `bytes`. This alias makes the rename
// more easily discoverable. // more easily discoverable.
#[cfg_attr(docsrs, doc(alias = "bytes"))] #[cfg_attr(docsrs, doc(alias = "bytes"))]
+1 -1
View File
@@ -165,7 +165,7 @@ pub unsafe trait BufMut {
/// ///
/// # Implementer notes /// # 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, /// slice **if and only if** `remaining_mut()` returns 0. In other words,
/// `chunk_mut()` returning an empty slice implies that `remaining_mut()` will /// `chunk_mut()` returning an empty slice implies that `remaining_mut()` will
/// return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will /// return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will