Post #2170321
2026-05-06 07:48 UTC
TIL: `get_disjoint_mut` exists. It allows getting mut refs to multiple elements of a slice. Previously one had to use the `split_at_mut` trick to achieve this.
When searching (or asking AIs) for this I still only find the `split_at_mut` approach.
#rust
https://doc.rust-lang.org/beta/std/primitive.slice.html#method.get_disjoint_mut
Replies (1)
-
@jamey@toot.cat 2026-05-06 08:54
@h4kor@chaos.social Yeah, that can be super useful! There's also a HashMap::get_disjoint_mut, which doesn't have an equivalent alternative like split_at_mut.