Consider adding extend_from_within to BytesMut, similar to Vec::extend_from_within.
Use case: append data that already exists in the buffer (e.g., duplicating a prefix/suffix for framing, rolling buffers, backreferences).
Current workaround: put_bytes to add placeholder bytes, then copy_within to overwrite them. This touches memory twice and is inefficient in hot paths.
Proposed API: Similar to Vec::extend_from_within.
impl BytesMut {
pub fn extend_from_within<R>(&mut self, src: R)
where
R: std::ops::RangeBounds<usize>;
}
Expected behavior: src is evaluated against the original buffer (like Vec::extend_from_within); out-of-bounds handling consistent with existing methods.
If this approach is acceptable, I’m happy to follow up with a PR—please let me know your preferred signature/semantics. Thanks for the great effort on a great crate!