mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-09-03 00:00:06 +02:00
doc: fix BytesMut growth documentation. (#321)
This commit is contained in:
committed by
Carl Lerche
parent
b7c1f2a135
commit
1db67b4a87
+3
-8
@@ -21,14 +21,9 @@ use crate::loom::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering};
|
|||||||
///
|
///
|
||||||
/// # Growth
|
/// # Growth
|
||||||
///
|
///
|
||||||
/// One key difference from `Vec<u8>` is that most operations **do not
|
/// `BytesMut`'s `BufMut` implementation will implicitly grow its buffer as
|
||||||
/// implicitly grow the buffer**. This means that calling `my_bytes.put("hello
|
/// necessary. However, explicitly reserving the required space up-front before
|
||||||
/// world");` could panic if `my_bytes` does not have enough capacity. Before
|
/// a series of inserts will be more efficient.
|
||||||
/// writing to the buffer, ensure that there is enough remaining capacity by
|
|
||||||
/// calling `my_bytes.remaining_mut()`. In general, avoiding calls to `reserve`
|
|
||||||
/// is preferable.
|
|
||||||
///
|
|
||||||
/// The only exception is `extend` which implicitly reserves required capacity.
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user