Auto merge of #103754 - SUPERCILEX:filled-mut, r=m-ou-se
Add back BorrowedBuf::filled_mut This is useful if you want to do some processing on the bytes while still using the BorrowedBuf. The API was removed in https://github.com/rust-lang/rust/pull/97015 with no explanation. The RFC also has it as part of its API, so this just seems like a mistake: [RFC](https://rust-lang.github.io/rfcs/2930-read-buf.html#:~:text=inline%5D%0A%20%20%20%20pub%20fn-,filled_mut,-(%26mut%20self)) ACP: https://github.com/rust-lang/libs-team/issues/139
This commit is contained in:
commit
48a814deab
@ -99,6 +99,13 @@ pub fn filled(&self) -> &[u8] {
|
||||
unsafe { MaybeUninit::slice_assume_init_ref(&self.buf[0..self.filled]) }
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the filled portion of the buffer.
|
||||
#[inline]
|
||||
pub fn filled_mut(&mut self) -> &mut [u8] {
|
||||
// SAFETY: We only slice the filled part of the buffer, which is always valid
|
||||
unsafe { MaybeUninit::slice_assume_init_mut(&mut self.buf[0..self.filled]) }
|
||||
}
|
||||
|
||||
/// Returns a cursor over the unfilled part of the buffer.
|
||||
#[inline]
|
||||
pub fn unfilled<'this>(&'this mut self) -> BorrowedCursor<'this> {
|
||||
|
Loading…
Reference in New Issue
Block a user