Aren't both ~vector and @vector dynamic memory? why can we append to a
~vector but not to a @vector?


--
Arkaitz



On Mon, Dec 10, 2012 at 10:38 PM, Patrick Walton <[email protected]>wrote:

> 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
>
> ______________________________**_________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/**listinfo/rust-dev<https://mail.mozilla.org/listinfo/rust-dev>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to