Skip to content

Commit 718dcc8

Browse files
authored
docs: BytesMut::with_capacity does not guarantee exact capacity (#5870)
1 parent 10e141d commit 718dcc8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tokio/src/io/util/async_read_ext.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,13 @@ cfg_io_util! {
230230
/// let mut buffer = BytesMut::with_capacity(10);
231231
///
232232
/// assert!(buffer.is_empty());
233+
/// assert!(buffer.capacity() >= 10);
233234
///
234-
/// // read up to 10 bytes, note that the return value is not needed
235-
/// // to access the data that was read as `buffer`'s internal
236-
/// // cursor is updated.
235+
/// // note that the return value is not needed to access the data
236+
/// // that was read as `buffer`'s internal cursor is updated.
237+
/// //
238+
/// // this might read more than 10 bytes if the capacity of `buffer`
239+
/// // is larger than 10.
237240
/// f.read_buf(&mut buffer).await?;
238241
///
239242
/// println!("The bytes: {:?}", &buffer[..]);

0 commit comments

Comments
 (0)