tokio-rs / bytes

Utilities for working with bytes
MIT License
1.86k stars 278 forks source link

Don't set `len` in `BytesMut::reserve` #682

Closed braddunbar closed 5 months ago

braddunbar commented 5 months ago

A fundamental invariant of reserve is that it can extend capacity while the stored data remains the same, even if it's moved to a new allocation. As a result, len can never change during a call to reserve.