[rust-dev] Swapping elements in a vec

Peter Hull peterhull90 at gmail.com
Sun Feb 27 13:51:14 PST 2011


Is it possible to swap elements in a vec? I tried
  let mutable vec[int] a = vec(1,2,3);
  let int t = a.(0);
  a.(0) = a.(1);
  a.(1) = t;
but rustboot says (quite rightly I suppose) that int is not mutable.

Pete
ps. hope you're not too disappointed I stuck to ASCII for my
identifiers, what's Chinese for 'a' anyway?!?


More information about the Rust-dev mailing list