You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structValue{n:int}implValue{fnsquared(mutself) -> Value{self.n *= self.n;self}}fnmain(){let x = Value{n:3};let y = x.squared();println!("{} {}", x.n, y.n);}
Prints out:
-> % rustc foo.rs && ./foo
9 9
The call to squared should be receiving a copy of x as the self param. This bug is only exhibited in the case of implicity copyable struct. If you add something like ~int to Value the compiler will rightly complain that x has been moved.
Also, if you add another field (like m: int) making Value an immediate no longer, we see the right behaviour: