Skip to content

Commit b0c1b95

Browse files
committed
Update comments and doctests
1 parent 5bbf7c2 commit b0c1b95

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

bytes/src/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
//! assert_eq!(shared4.len(), 60);
1818
//!
1919
//! for byte in shared1.iter_mut() { *byte = 1u8; }
20-
//! for byte in shared2.iter_mut() { *byte = 2u8; }
21-
//! for byte in shared3.iter_mut() { *byte = 3u8; }
22-
//! for byte in shared4.iter_mut() { *byte = 4u8; }
2320
//!
2421
//! // memory in slabs [4, 2, 3, 1]: merge back in arbitrary order.
2522
//! shared2.try_merge(shared3).ok().expect("Failed to merge 2 and 3");
26-
//! shared2.try_merge(shared1).ok().expect("Failed to merge 23 and 1");
23+
//! shared2.try_merge(shared1.freeze()).ok().expect("Failed to merge 23 and 1");
2724
//! shared4.try_merge(shared2).ok().expect("Failed to merge 4 and 231");
2825
//!
2926
//! assert_eq!(shared4.len(), 1024);
@@ -84,12 +81,12 @@ pub mod arc {
8481
}
8582
}
8683

87-
/// Extracts [0, index) into a new `BytesMut` which is returned, updating `self`.
84+
/// Extracts [0, index) into a new `Bytes` which is returned, updating `self`.
8885
///
8986
/// # Safety
9087
///
9188
/// This method first tests `index` against `self.len`, which should ensure that both
92-
/// the returned `BytesMut` contains valid memory, and that `self` can no longer access it.
89+
/// the returned `Bytes` contains valid memory, and that `self` can no longer access it.
9390
pub fn extract_to(&mut self, index: usize) -> Bytes {
9491

9592
assert!(index <= self.len);
@@ -123,11 +120,11 @@ pub mod arc {
123120
/// let mut shared3 = shared1.extract_to(100);
124121
/// let mut shared4 = shared2.extract_to(60);
125122
///
126-
/// drop(shared1);
123+
/// drop(shared3);
127124
/// drop(shared2);
128125
/// drop(shared4);
129-
/// assert!(shared3.try_regenerate::<Vec<u8>>());
130-
/// assert!(shared3.len() == 1024);
126+
/// assert!(shared1.try_regenerate::<Vec<u8>>());
127+
/// assert!(shared1.len() == 1024);
131128
/// ```
132129
pub fn try_regenerate<B>(&mut self) -> bool where B: DerefMut<Target=[u8]>+'static {
133130
// Only possible if this is the only reference to the sequestered allocation.
@@ -191,12 +188,12 @@ pub mod arc {
191188

192189
impl Bytes {
193190

194-
/// Extracts [0, index) into a new `BytesMut` which is returned, updating `self`.
191+
/// Extracts [0, index) into a new `Bytes` which is returned, updating `self`.
195192
///
196193
/// # Safety
197194
///
198195
/// This method first tests `index` against `self.len`, which should ensure that both
199-
/// the returned `BytesMut` contains valid memory, and that `self` can no longer access it.
196+
/// the returned `Bytes` contains valid memory, and that `self` can no longer access it.
200197
pub fn extract_to(&mut self, index: usize) -> Bytes {
201198

202199
assert!(index <= self.len);
@@ -225,7 +222,7 @@ pub mod arc {
225222
/// use timely_bytes::arc::BytesMut;
226223
///
227224
/// let bytes = vec![0u8; 1024];
228-
/// let mut shared1 = BytesMut::from(bytes);
225+
/// let mut shared1 = BytesMut::from(bytes).freeze();
229226
/// let mut shared2 = shared1.extract_to(100);
230227
/// let mut shared3 = shared1.extract_to(100);
231228
/// let mut shared4 = shared2.extract_to(60);

0 commit comments

Comments
 (0)