// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(unknown_features)] #![feature(box_syntax)] fn match_on_local() { let mut foo: Option> = Some(box 5); match foo { None => {}, Some(x) => { foo = Some(x); } } println!("'{}'", foo.unwrap()); } fn match_on_arg(mut foo: Option>) { match foo { None => {} Some(x) => { foo = Some(x); } } println!("'{}'", foo.unwrap()); } fn match_on_binding() { match Some(Box::new(7)) { mut foo => { match foo { None => {}, Some(x) => { foo = Some(x); } } println!("'{}'", foo.unwrap()); } } } fn match_on_upvar() { let mut foo: Option> = Some(box 8); let f = move|| { match foo { None => {}, Some(x) => { foo = Some(x); } } println!("'{}'", foo.unwrap()); }; f(); } fn main() { match_on_local(); match_on_arg(Some(box 6)); match_on_binding(); match_on_upvar(); }