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);
|
2019-04-22 02:40:08 -05:00
|
|
|
x
|
|
|
|
//~^ NOTE borrow of `x` occurs here
|
2015-09-10 19:16:57 -05:00
|
|
|
+=
|
2019-04-22 02:40:08 -05:00
|
|
|
x;
|
|
|
|
//~^ ERROR cannot move out of `x` because it is borrowed
|
|
|
|
//~| move out of `x` occurs here
|
2015-09-10 19:16:57 -05:00
|
|
|
|
|
|
|
let y = Int(2);
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ HELP consider changing this to be mutable
|
2023-01-01 02:06:31 -06:00
|
|
|
//~| SUGGESTION mut
|
2019-04-22 02:40:08 -05:00
|
|
|
y //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable
|
|
|
|
//~| cannot borrow as mutable
|
2015-09-10 19:16:57 -05:00
|
|
|
+=
|
|
|
|
Int(1);
|
|
|
|
}
|