rust/src/test/run-pass/alt-ref-binding.rs

11 lines
158 B
Rust
Raw Normal View History

2012-08-20 19:23:37 +00:00
fn destructure(x: Option<int>) -> int {
2012-08-06 23:13:52 +00:00
match x {
2012-08-20 19:23:37 +00:00
None => 0,
Some(ref v) => *v
}
}
fn main() {
2012-08-20 19:23:37 +00:00
assert destructure(Some(22)) == 22;
2012-08-06 23:13:52 +00:00
}