array2d icon indicating copy to clipboard operation
array2d copied to clipboard

Is it possible to swap two values at known indices?

Open PartyWumpus opened this issue 1 year ago • 0 comments

If I was using a vec of vecs, this would be reasonably easy:

if they're in the same inner vec then just

arr.swap(index1, index2)

and if they're in different vecs then i can get a mutable reference to each and just

std::mem::swap(&mut value1, &mut value2)

I can't figure out a way to do this with the API you make available, even with std::ptr::swap

PartyWumpus avatar Apr 23 '24 21:04 PartyWumpus