mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-17 00:00:11 +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);
|
||||
///
|
||||
/// 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[..]);
|
||||
|
||||
Reference in New Issue
Block a user