Skip to content

Commit

Permalink
doc: fix BytesMut growth documentation. (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler authored and carllerche committed Nov 25, 2019
1 parent b7c1f2a commit 1db67b4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/bytes_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit 1db67b4

Please sign in to comment.