@@ -992,16 +992,27 @@ impl<'a, const N: usize> SplitGrantR<'a, N> {
992
992
/// let buffer: BBBuffer<6> = BBBuffer::new();
993
993
/// let (mut prod, mut cons) = buffer.try_split().unwrap();
994
994
///
995
- /// // Successfully obtain and commit a grant of four bytes
996
- /// let mut grant = prod.grant_max_remaining(4 ).unwrap();
997
- /// grant.buf().copy_from_slice(&[1, 2, 3, 4]);
998
- /// grant.commit(4 );
995
+ /// // Successfully obtain and commit a grant of six bytes filling the buffer
996
+ /// let mut grant = prod.grant_max_remaining(6 ).unwrap();
997
+ /// grant.buf().copy_from_slice(&[1, 2, 3, 4, 5, 6 ]);
998
+ /// grant.commit(6 );
999
999
///
1000
- /// // Obtain a read grant, and copy to a buffer
1000
+ /// // Obtain a read grant of all six bytes, but only release four bytes
1001
1001
/// let mut grant = cons.read().unwrap();
1002
- /// let mut buf = [0u8; 4];
1003
- /// buf.copy_from_slice(grant.buf());
1004
- /// assert_eq!(&buf, &[1, 2, 3, 4]);
1002
+ /// assert_eq!(grant.buf(), &[1, 2, 3, 4, 5, 6]);
1003
+ /// grant.release(4);
1004
+ ///
1005
+ /// // Successfully obtain and commit a grant of two bytes again at the start
1006
+ /// // of the buffer creating a split buffer
1007
+ /// let mut grant = prod.grant_max_remaining(2).unwrap();
1008
+ /// grant.buf().copy_from_slice(&[7, 8]);
1009
+ /// grant.commit(2);
1010
+ ///
1011
+ /// // Obtain a split read grant and release the buffer
1012
+ /// let mut grant = cons.split_read().unwrap();
1013
+ /// assert_eq!(grant.bufs(), ([5, 6].as_ref(), [7, 8].as_ref()));
1014
+ /// grant.release(4);
1015
+ ///
1005
1016
/// # // bbqueue test shim!
1006
1017
/// # }
1007
1018
/// #
0 commit comments