docs: BytesMut::with_capacity does not guarantee exact capacity (#5870)

This commit is contained in:
mahkoh
2023-08-16 10:29:29 -07:00
committed by GitHub
parent 10e141d211
commit 718dcc8dff
+6 -3
View File
@@ -230,10 +230,13 @@ cfg_io_util! {
/// let mut buffer = BytesMut::with_capacity(10);
///
/// assert!(buffer.is_empty());
/// assert!(buffer.capacity() >= 10);
///
/// // read up to 10 bytes, note that the return value is not needed
/// // to access the data that was read as `buffer`'s internal
/// // cursor is updated.
/// // note that the return value is not needed to access the data
/// // that was read as `buffer`'s internal cursor is updated.
/// //
/// // this might read more than 10 bytes if the capacity of `buffer`
/// // is larger than 10.
/// f.read_buf(&mut buffer).await?;
///
/// println!("The bytes: {:?}", &buffer[..]);