tokio-rs / bytes

Utilities for working with bytes
MIT License
1.91k stars 288 forks source link

[Question] Is it reasonable to have cost efficient constructor for BytesMut? #594

Open ileixe opened 1 year ago

ileixe commented 1 year ago

Currently, BytesMut seems to require buffer allocation when converted from other types: https://docs.rs/bytes/latest/src/bytes/bytes_mut.rs.html#1172

Is there any reason not to provide allocation-free BytesMut constructor like https://docs.rs/bytes/latest/src/bytes/bytes.rs.html#843? (I'd like to use Box<[u8]> to create BytesMut as well. )