NULLx76 / ringbuffer

A fixed-size circular buffer written in Rust.
https://crates.io/crates/ringbuffer
MIT License
95 stars 20 forks source link

Fix mut iter #26

Closed jdonszelmann closed 4 years ago

jdonszelmann commented 4 years ago

Closes #25

Plecra commented 4 years ago

(After briefly skimming on my phone,) I think running with #27 is a good call.

As for the soundness of this PR, get_mut_impl is not a solution. Instead, RingBuffer should be an unsafe trait, and the safety documentation could just be added to get_mut. unsafe fns are unsafe to call, not implement.

That said, this PR does seem to be a fix at first glance - sealing RingBuffer prevents misuse, and the trait is still used properly internally (though the unsafety should be documented properly anyway).

NULLx76 commented 4 years ago

@Plecra Thanks for your input, has been helpful!