On 27/02/2011 1:51 PM, Peter Hull wrote:
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.

Yeah. You want vec[mutable int]. We'll probably wind up with a 'swap' primitive at some point down the line when unique ownership and move semantics are more thoroughly worked out.

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

No need for this. We have a clear conduct guideline about insulting and baiting speech. Please refrain from it in the future.

-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to