]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 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 | ||
c34b1796 | 11 | |
1a4d82fc JJ |
12 | mod foo { |
13 | pub trait Value { | |
c34b1796 | 14 | fn value(&self) -> usize; |
1a4d82fc JJ |
15 | } |
16 | } | |
17 | ||
c34b1796 | 18 | static BLOCK_USE: usize = { |
1a4d82fc JJ |
19 | use foo::Value; |
20 | 100 | |
21 | }; | |
22 | ||
c34b1796 | 23 | static BLOCK_STRUCT_DEF: usize = { |
1a4d82fc | 24 | struct Foo { |
c34b1796 | 25 | a: usize |
1a4d82fc JJ |
26 | } |
27 | Foo{ a: 300 }.a | |
28 | }; | |
29 | ||
c34b1796 AL |
30 | static BLOCK_FN_DEF: fn(usize) -> usize = { |
31 | fn foo(a: usize) -> usize { | |
1a4d82fc JJ |
32 | a + 10 |
33 | } | |
34 | foo | |
35 | }; | |
36 | ||
c34b1796 | 37 | static BLOCK_MACRO_RULES: usize = { |
1a4d82fc JJ |
38 | macro_rules! baz { |
39 | () => (412) | |
40 | } | |
41 | baz!() | |
42 | }; | |
43 | ||
44 | pub fn main() { | |
45 | assert_eq!(BLOCK_USE, 100); | |
1a4d82fc JJ |
46 | assert_eq!(BLOCK_STRUCT_DEF, 300); |
47 | assert_eq!(BLOCK_FN_DEF(390), 400); | |
48 | assert_eq!(BLOCK_MACRO_RULES, 412); | |
49 | } |