Closed lynzrand closed 3 years ago
I just implemented the unsafe version. It passed miri test
s on my machine. Implementation notes are next to the code.
A quick note here:
According to lifetime elision rules, get2_mut(&mut self, Index, Index) -> (Option<&mut T>, Option<&mut T>)
has the same lifetime as get2_mut(&'a mut self, Index, Index) -> (Option<&'a mut T>, Option<&'a mut T>)
. This means the function exports the expected lifetimes for references.
Implementation is looking good, my comment is mostly a style nit.
Can you also add an entry to CHANGELOG.md
that notes that Arena::get2_mut
is an unreleased change? Thanks!
Added!
Ignore the force push please... That was just me trying to fix a style issue without wasting another commit and failed. I promise I won't do that the next time!
Thanks! :D
This PR adds
Arena::get2_mut
that returns mutable reference to two items of different indices at once.This PR closes #21.
Well... there's definitely some code gymnastics inside to implementing this thing in safe Rust. Is there a better way to implement this,
or maybe an unsafe implementation could be preferred?