On 2013-11-22, at 7:42, Patrick Walton <pcwal...@mozilla.com> wrote: > > I think it's unlikely that the performance hit there would be significant. > Actually, the example you gave, there won't be any at all because it'll be > devirtualized and inlined.
Oh, okay, that's good to hear. > > There is `move_iter`, but that only works for owned vectors. Perhaps what you > want is a kind of iterator that clones its values... > I suppose what .map(|a| a.clone()) does would be a generalization of that. Although I don't know what that does exactly. Now, off-topic: I've been trying to post the following question to this mailing list for like 4 times, but no dice. I seem to have better luck when replying to posts, so here it goes: struct Value { n: int } impl Value { fn squared(mut self) -> Value { self.n *= self.n; self } } fn main() { let x = Value{ n: 3 }; let y = x.squared(); println!("{} {}", x.n, y.n); // prints 9 9 } self isn't being passed by value to squared, since x.n gets mutated as well. This must be a bug, right?
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev