You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some applications may want the capacity of BytesMut to be reported exactly as previously requested (unless more is already reserved). BytesMut::reserve allows for allocation excess and over-reserving in expectation for further expansion, which is probably good for the general case. Hence the proposal for another method.
As I understand it, the stumbling block here is the Vec representation: Vec::reserve_exact does not actually guarantee the exact capacity, and the cap member of BytesMut is tied to the virtual Vec and so can't be fudged without breaking safety for Vec::from_raw_parts. So extra bookkeeping would be needed to implement this.
Some applications may want the capacity of
BytesMut
to be reported exactly as previously requested (unless more is already reserved).BytesMut::reserve
allows for allocation excess and over-reserving in expectation for further expansion, which is probably good for the general case. Hence the proposal for another method.For an example where this could save on external bookkeeping, see mzabaluev/chunked-bytes#1
The text was updated successfully, but these errors were encountered: