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

Peter Ronnquist peter.ronnquist at gmail.com
Mon Dec 10 14:34:52 PST 2012


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_2.push(Bat_(bat));  // Line 124

rustc says:

banoid.rs:124:24: 124:38 error: attempted access of field `push` on type
`&mut @[Object]`, but no field or method with that name was found
banoid.rs:124                         objects_2.push(Bat_(bat));

It looks like the vector module only implements push(...) for "impl<T>
~[T]: MutableVector<T>".

I would appreciate if anyone could comment on this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121210/20cfdb4b/attachment.html>

More information about the Rust-dev mailing list