Is it safe to reuse buffer for poll_frame? #3603
-
Hi everyone, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
But, yes, it's safe. From the docs of
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
This is described more here: https://docs.rs/bytes/latest/bytes/struct.BytesMut.html#method.reserve