Skip to content

Commit 818ba56

Browse files
committed
Add non mut spare_capacity().
1 parent 4b53a29 commit 818ba56

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/bytes_mut.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,11 @@ impl BytesMut {
11171117
slice::from_raw_parts_mut(ptr.cast(), len)
11181118
}
11191119
}
1120+
/// Returns the remaining spare capacity of the buffer.
1121+
#[inline]
1122+
pub fn spare_capacity(&self) -> usize {
1123+
self.cap - self.len
1124+
}
11201125
}
11211126

11221127
impl Drop for BytesMut {

0 commit comments

Comments
 (0)