2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2017-10-06 15:30:23 -05:00
|
|
|
enum Wrapper {
|
|
|
|
Wrap(i32),
|
|
|
|
}
|
|
|
|
|
|
|
|
use Wrapper::Wrap;
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let Wrap(x) = &Wrap(3);
|
|
|
|
println!("{}", *x);
|
|
|
|
|
|
|
|
let Wrap(x) = &mut Wrap(3);
|
|
|
|
println!("{}", *x);
|
|
|
|
|
|
|
|
if let Some(x) = &Some(3) {
|
|
|
|
println!("{}", *x);
|
|
|
|
} else {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(x) = &mut Some(3) {
|
|
|
|
println!("{}", *x);
|
|
|
|
} else {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(x) = &mut Some(3) {
|
|
|
|
*x += 1;
|
|
|
|
} else {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
while let Some(x) = &Some(3) {
|
|
|
|
println!("{}", *x);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while let Some(x) = &mut Some(3) {
|
|
|
|
println!("{}", *x);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while let Some(x) = &mut Some(3) {
|
|
|
|
*x += 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|