2012-04-26 23:02:01 +00:00
|
|
|
fn main() {
|
2015-01-08 10:54:35 +00:00
|
|
|
let mut x: Option<isize> = None;
|
2013-03-15 19:24:24 +00:00
|
|
|
match x {
|
|
|
|
None => {
|
|
|
|
// Note: on this branch, no borrow has occurred.
|
|
|
|
x = Some(0);
|
|
|
|
}
|
2012-08-20 19:23:37 +00:00
|
|
|
Some(ref i) => {
|
2013-03-15 19:24:24 +00:00
|
|
|
// But on this branch, `i` is an outstanding borrow
|
2019-04-22 07:40:08 +00:00
|
|
|
x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed
|
2018-04-09 09:28:00 +00:00
|
|
|
drop(i);
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-02 19:47:32 +00:00
|
|
|
x.clone(); // just to prevent liveness warnings
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|