2013-03-15 19:24:24 +00:00
|
|
|
fn separate_arms() {
|
2019-04-22 07:40:08 +00:00
|
|
|
// Here both arms perform assignments, but only one is illegal.
|
2013-03-15 19:24:24 +00:00
|
|
|
|
|
|
|
let mut x = None;
|
|
|
|
match x {
|
|
|
|
None => {
|
|
|
|
// It is ok to reassign x here, because there is in
|
|
|
|
// fact no outstanding loan of x!
|
2015-01-31 16:23:42 +00:00
|
|
|
x = Some(0);
|
2013-03-15 19:24:24 +00:00
|
|
|
}
|
2018-04-09 09:28:00 +00:00
|
|
|
Some(ref r) => {
|
2019-04-22 07:40:08 +00:00
|
|
|
x = Some(1); //~ ERROR cannot assign to `x` because it is borrowed
|
2018-04-09 09:28:00 +00:00
|
|
|
drop(r);
|
2013-03-15 19:24:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|