Commit | Line | Data |
---|---|---|
67218854 TT |
1 | // Copyright (C) 2016 Free Software Foundation, Inc. |
2 | ||
3 | // This program is free software; you can redistribute it and/or modify | |
4 | // it under the terms of the GNU General Public License as published by | |
5 | // the Free Software Foundation; either version 3 of the License, or | |
6 | // (at your option) any later version. | |
7 | // | |
8 | // This program is distributed in the hope that it will be useful, | |
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | // GNU General Public License for more details. | |
12 | // | |
13 | // You should have received a copy of the GNU General Public License | |
14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | #![allow(dead_code)] | |
17 | #![allow(unused_variables)] | |
18 | #![allow(unused_assignments)] | |
19 | ||
20 | ||
21 | pub struct HiBob { | |
22 | pub field1: i32, | |
23 | field2: u64, | |
24 | } | |
25 | ||
26 | struct ByeBob(i32, u64); | |
27 | ||
28 | enum Something { | |
29 | One, | |
30 | Two, | |
31 | Three | |
32 | } | |
33 | ||
34 | enum MoreComplicated { | |
35 | One, | |
36 | Two(i32), | |
37 | Three(HiBob), | |
38 | Four{this: bool, is: u8, a: char, struct_: u64, variant: u32}, | |
39 | } | |
40 | ||
41 | fn diff2(x: i32, y: i32) -> i32 { | |
42 | x - y | |
43 | } | |
44 | ||
45 | pub struct Unit; | |
46 | ||
47 | // This triggers the non-zero optimization that yields a different | |
48 | // enum representation in the debug info. | |
49 | enum SpaceSaver { | |
50 | Thebox(u8, Box<i32>), | |
51 | Nothing, | |
52 | } | |
53 | ||
54 | fn main () { | |
55 | let a = (); | |
56 | let b : [i32; 0] = []; | |
57 | ||
58 | let mut c = 27; | |
59 | let d = c = 99; | |
60 | ||
61 | let e = MoreComplicated::Two(73); | |
62 | let e2 = MoreComplicated::Four {this: true, is: 8, a: 'm', | |
63 | struct_: 100, variant: 10}; | |
64 | ||
65 | let f = "hi bob"; | |
66 | let g = b"hi bob"; | |
67 | let h = b'9'; | |
68 | ||
69 | let i = ["whatever"; 8]; | |
70 | ||
71 | let j = Unit; | |
72 | ||
73 | let k = SpaceSaver::Nothing; | |
74 | let l = SpaceSaver::Thebox(9, Box::new(1729)); | |
75 | ||
76 | let v = Something::Three; | |
77 | let w = [1,2,3,4]; | |
78 | let x = (23, 25.5); | |
79 | let y = HiBob {field1: 7, field2: 8}; | |
80 | let z = ByeBob(7, 8); | |
81 | ||
82 | let slice = &w[2..3]; | |
83 | let fromslice = slice[0]; | |
84 | let slice2 = &slice[0..1]; | |
85 | ||
86 | let all1 = &w[..]; | |
87 | let all2 = &slice[..]; | |
88 | ||
89 | let from1 = &w[1..]; | |
90 | let from2 = &slice[1..]; | |
91 | ||
92 | let to1 = &w[..3]; | |
93 | let to2 = &slice[..1]; | |
94 | ||
95 | println!("{}, {}", x.0, x.1); // set breakpoint here | |
96 | println!("{}", diff2(92, 45)); | |
97 | } |