In #698, the behavior of BytesMut::advance was changed to clear the buffer instead of reduce capacity when the advanced count matched remaining. In s2n-quic, we rely on advance actually reducing remaining and have several data structures and trait impls that rely on this behavior:
In its current state, there's no longer an efficient way to actually reduce capacity of BytesMut, since the only other option is to call split_to and discard the result, which isn't great since you churn on reference counts, which is kind of the whole point of advance, as indicated by the #[must_use] attribute: consider BytesMut::advance if you don't need the other half.
My vote would be to revert this change.
In #698, the behavior of
BytesMut::advancewas changed to clear the buffer instead of reduce capacity when the advanced count matchedremaining. In s2n-quic, we rely onadvanceactually reducingremainingand have several data structures and trait impls that rely on this behavior:In its current state, there's no longer an efficient way to actually reduce capacity of
BytesMut, since the only other option is to callsplit_toand discard the result, which isn't great since you churn on reference counts, which is kind of the whole point ofadvance, as indicated by the#[must_use]attribute:consider BytesMut::advance if you don't need the other half.My vote would be to revert this change.