|
| 1 | +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +trait Boo { } |
| 12 | + |
| 13 | +impl Boo for [i8; 1] { } |
| 14 | +impl Boo for [i8; 2] { } |
| 15 | +impl Boo for [i8; 3] { } |
| 16 | +impl Boo for [i8; 4] { } |
| 17 | + |
| 18 | +pub fn foo(box_1: fn () -> Box<[i8; 1]>, |
| 19 | + box_2: fn () -> Box<[i8; 20]>, |
| 20 | + box_3: fn () -> Box<[i8; 300]>, |
| 21 | + box_4: fn () -> Box<[i8; 4000]>, |
| 22 | + ) { |
| 23 | + println!("Hello World 1"); |
| 24 | + let _: Box<[i8]> = match 3 { |
| 25 | + 1 => box_1(), |
| 26 | + 2 => box_2(), |
| 27 | + 3 => box_3(), |
| 28 | + _ => box_4(), |
| 29 | + }; |
| 30 | + println!("Hello World 2"); |
| 31 | +} |
| 32 | + |
| 33 | +pub fn main() { |
| 34 | + fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) } |
| 35 | + fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) } |
| 36 | + fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) } |
| 37 | + fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) } |
| 38 | + |
| 39 | + foo(box_1, box_2, box_3, box_4); |
| 40 | +} |
0 commit comments