1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
struct T {
iterm1: i32,
iterm2: i32,
}
fn test_fn((a, b): (i32, i32)) {
println!("{} {}", a, b);
}
fn main() {
let tuple = (1i32, 2i32);
let (first, second) = tuple;
let callable = |(a, b): (i32, i32)| {
println!("{} {}", a, b);
};
println!("{} {}", first, second);
test_fn(tuple);
callable(tuple);
let t = T {
iterm1: 1,
iterm2: 2,
};
let T {
iterm1: i1,
iterm2: i2,
} = t;
println!("{} {}", i1, i2);
let T { iterm1: ii1, .. } = t;
println!("{}", ii1);
let a = 1i32;
match a {
0..=1 => println!("a = 1"),
_ => println!("default"),
}
let b = Some(1);
if let Some(num) = b {
println!("num = {}", num)
}
let arr = vec![1, 2, 3];
for (index, val) in arr.iter().enumerate() {
println!("{} => {}", index, val);
}
}
|