rust/src/test/run-pass/shadow.rs

31 lines
897 B
Rust
Raw Normal View History

// Copyright 2012 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(c: Vec<isize> ) {
let a: isize = 5;
let mut b: Vec<isize> = Vec::new();
2011-07-27 07:19:39 -05:00
match t::none::<isize> {
t::some::<isize>(_) => {
2015-01-31 11:20:46 -06:00
for _i in &c {
2014-10-14 20:07:11 -05:00
println!("{}", a);
2015-01-25 15:05:03 -06:00
let a = 17;
b.push(a);
}
}
_ => { }
}
}
enum t<T> { none, some(T), }
pub fn main() { let x = 10; let x = x + 20; assert_eq!(x, 30); foo(Vec::new()); }