[rust-dev] problems with adding an element to a ' @' vector.

Peter Ronnquist peter.ronnquist at gmail.com
Mon Dec 10 15:35:21 PST 2012


>On 12/10/12 2:34 PM, Peter Ronnquist wrote:
>>* Hi,*>>**>>* I am having problems with adding an element to a '@' vector in rust 0.4.*>>**>>* The following works fine with a "~" vector but not with a '@' vector:*>>**>>*                          let mut objects_1 : &mut ~[Object] =  &mut ~[];*>>*                          let mut objects_2 : &mut @[Object] =  &mut @[];*>>**>>*                          objects_1.push(Bat_(bat));*>>*                          objects_2.push(Bat_(bat));  // Line 124>*
>Appending to an `@` vector would require copying the entire vector, just
>as with arrays in Java. (We should still probably support `push` on it
>with this performance caveat, but that's the reason why we don't right now.)
>
>If you want to append to a vector, you probably want the `DVec` type, or
>a ~vector.
>
>Patrick

I will try DVec,thank you for the quick reply.

Regards
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121211/90b0803b/attachment.html>


More information about the Rust-dev mailing list