2018-10-12 11:43:13 -05:00
|
|
|
// issue-52240: Can turn immutable into mut with `ref mut`
|
|
|
|
|
|
|
|
enum Foo {
|
|
|
|
Bar(i32),
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let arr = vec!(Foo::Bar(0));
|
|
|
|
if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ ERROR cannot borrow data in a `&` reference as mutable
|
2018-10-12 11:43:13 -05:00
|
|
|
*val = 9001;
|
|
|
|
}
|
|
|
|
match arr[0] {
|
|
|
|
Foo::Bar(ref s) => println!("{}", s)
|
|
|
|
}
|
|
|
|
}
|