Repository navigation
Is it safe to reuse buffer for poll_frame? #3603
|
Hi everyone, |
Replies: 2 comments 4 replies
|
But, yes, it's safe. From the docs of
|
|
It could be safe. BytesMut does that when you split and freeze. But it does atomic ref counting to make sure no frozen slices still exist. If done wrong, it is unsafe and can be Undefined Behavior. If you're doing all that manually, I'd recommend using BytesMut safe methods to do that instead. |
This is described more here: https://docs.rs/bytes/latest/bytes/struct.BytesMut.html#method.reserve