blob: f02c46fb8f0fd313a063df7da269372415deaaf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
fn main() {
let mut x: Option<isize> = None;
match x {
None => {
// Note: on this branch, no borrow has occurred.
x = Some(0);
}
Some(ref i) => {
// But on this branch, `i` is an outstanding borrow
x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed
drop(i);
}
}
x.clone(); // just to prevent liveness warnings
}
|