2015-09-10 19:16:57 -05:00
|
|
|
use std::ops::AddAssign;
|
|
|
|
|
|
|
|
struct Int(i32);
|
|
|
|
|
|
|
|
impl AddAssign for Int {
|
|
|
|
fn add_assign(&mut self, _: Int) {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = Int(1);
|
|
|
|
x //~ error: use of moved value: `x`
|
2016-04-20 14:42:13 -04:00
|
|
|
//~^ value used here after move
|
2015-09-10 19:16:57 -05:00
|
|
|
+=
|
2016-04-20 14:42:13 -04:00
|
|
|
x; //~ value moved here
|
2015-09-10 19:16:57 -05:00
|
|
|
|
|
|
|
let y = Int(2);
|
2018-09-12 14:13:40 -04:00
|
|
|
//~^ HELP make this binding mutable
|
|
|
|
//~| SUGGESTION mut y
|
2015-09-10 19:16:57 -05:00
|
|
|
y //~ error: cannot borrow immutable local variable `y` as mutable
|
2016-05-12 16:39:09 -07:00
|
|
|
//~| cannot borrow
|
2015-09-10 19:16:57 -05:00
|
|
|
+=
|
|
|
|
Int(1);
|
|
|
|
}
|