Open
Description
I see APIs have been proposed like this before but all I want is a method to try to unsplit a Bytes
as I think that should be possible in many cases, and if it fails the user can choose to perform a copy:
impl Bytes {
/// If `self` and `other` are adjacent in the underlying buffer, widen `self` to encompass both slices.
pub fn try_unsplit(&mut self, other: Bytes) -> Result<(), Bytes> { ... }
}
if let Err(other) = bytes.try_unsplit(other) {
bytes.extend_from_slice(&other);
}
I'd like it to take self
by mutable reference as that's generally more versatile and matches the signature of BytesMut::unsplit()
.
Metadata
Metadata
Assignees
Labels
No labels