Skip to content

Commit

Permalink
docs: BytesMut::with_capacity does not guarantee exact capacity (#5870)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Aug 16, 2023
1 parent 10e141d commit 718dcc8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tokio/src/io/util/async_read_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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[..]);
Expand Down

0 comments on commit 718dcc8

Please sign in to comment.