Swapping between Vec elements in Rust can be a little tricky. The get method returns Option<&T>, and the lone swap method accepts an index and a value – not a reference. There is an alternative, though. But it uses unsafe codes.
Swapping between Vec elements in Rust can be a little tricky. The get method returns Option<&T>, and the lone swap method accepts an index and a value – not a reference. There is an alternative, though. But it uses unsafe codes.