Is get2_unchecked_mut redundant?
Ralith opened this issue · 3 comments
It's unclear to me why this should ever be preferred over calling get_unchecked
twice. Can we avoid maintaining an extra interface here?
get_unchecked_mut
mutably borrows the Slab
, so the interface doesn't permit mutably borrowing a second item while one is already borrowed. get2_unchecked_mut
can be used to mutate two entries at a time (such as mem::swap
ping them).
Fair enough!
I notice the docs for get2_mut
explain the use-case for it:
Lines 693 to 709 in 3340fdc
but the docs for
get2_unchecked_mut
don't, really:Lines 783 to 787 in 3340fdc
Maybe we could make this a little clearer by having the doc comment for get2_unchecked_mut
explain the intended use-case, or adding a "This is a version of [get2_mut
] that doesn't perform bounds and safety condition checks" or something?