Does it imply that in Rust any type can be moved even the one that have custom destructor? Thus it is not possible to have, for example, a stack-allocated struct that reference itself via a pointer?
On 24 October 2013 16:23, Corey Richardson <[email protected]> wrote: > It's not necessary for U because there are no clones here, only moves. > > On Thu, Oct 24, 2013 at 6:07 AM, Igor Bukanov <[email protected]> wrote: >> Here is the map example from the tutorial, >> http://static.rust-lang.org/doc/master/tutorial.html#generics , >> >> fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { >> let mut accumulator = ~[]; >> for element in vector.iter() { >> accumulator.push(function(element)); >> } >> return accumulator; >> } >> >> >> It compiles even if the Clone trait is not specified for U and the >> push is defined as: >> >> fn push(&mut self, t: T); >> >> which I suppose implies a copy operation for T. So why the Clone trait >> is not necessary here for U? >> _______________________________________________ >> Rust-dev mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/rust-dev _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
