Guarantee address in split_off/split_to for empty slices (#740)

Signed-off-by: Alice Ryhl <[email protected]>
This commit is contained in:
Alice Ryhl
2024-10-18 19:46:49 +02:00
committed by GitHub
parent d7c1d658d9
commit 0ac54ca706
3 changed files with 111 additions and 6 deletions
+3 -1
View File
@@ -291,7 +291,9 @@ impl BytesMut {
/// Splits the bytes into two at the given index.
///
/// Afterwards `self` contains elements `[0, at)`, and the returned
/// `BytesMut` contains elements `[at, capacity)`.
/// `BytesMut` contains elements `[at, capacity)`. It's guaranteed that the
/// memory does not move, that is, the address of `self` does not change,
/// and the address of the returned slice is `at` bytes after that.
///
/// This is an `O(1)` operation that just increases the reference count
/// and sets a few indices.