mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
docs: BytesMut::with_capacity does not guarantee exact capacity (#5870)
This commit is contained in:
@@ -230,10 +230,13 @@ cfg_io_util! {
|
|||||||
/// let mut buffer = BytesMut::with_capacity(10);
|
/// let mut buffer = BytesMut::with_capacity(10);
|
||||||
///
|
///
|
||||||
/// assert!(buffer.is_empty());
|
/// assert!(buffer.is_empty());
|
||||||
|
/// assert!(buffer.capacity() >= 10);
|
||||||
///
|
///
|
||||||
/// // read up to 10 bytes, note that the return value is not needed
|
/// // note that the return value is not needed to access the data
|
||||||
/// // to access the data that was read as `buffer`'s internal
|
/// // that was read as `buffer`'s internal cursor is updated.
|
||||||
/// // 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?;
|
/// f.read_buf(&mut buffer).await?;
|
||||||
///
|
///
|
||||||
/// println!("The bytes: {:?}", &buffer[..]);
|
/// println!("The bytes: {:?}", &buffer[..]);
|
||||||
|
|||||||
Reference in New Issue
Block a user