diff options
author | 2019-11-25 14:40:40 -0500 | |
---|---|---|
committer | 2019-11-25 11:40:40 -0800 | |
commit | 1db67b4a870d2de4a582742403d3a6a49992761d (patch) | |
tree | de2bfbd55b54319d10a797ab61e548c29d3089e3 /src | |
parent | b7c1f2a1357f7f9cdf2eb0187398fc80aaf7e28d (diff) | |
download | bytes-1db67b4a870d2de4a582742403d3a6a49992761d.tar.gz bytes-1db67b4a870d2de4a582742403d3a6a49992761d.tar.zst bytes-1db67b4a870d2de4a582742403d3a6a49992761d.zip |
doc: fix BytesMut growth documentation. (#321)
Diffstat (limited to 'src')
-rw-r--r-- | src/bytes_mut.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index ea71a9a..85843a0 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -21,14 +21,9 @@ use crate::loom::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering}; /// /// # Growth /// -/// One key difference from `Vec<u8>` is that most operations **do not -/// implicitly grow the buffer**. This means that calling `my_bytes.put("hello -/// world");` could panic if `my_bytes` does not have enough capacity. Before -/// 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. +/// `BytesMut`'s `BufMut` implementation will implicitly grow its buffer as +/// necessary. However, explicitly reserving the required space up-front before +/// a series of inserts will be more efficient. /// /// # Examples /// |