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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// fn main() {
// let s = String::from("Hello world");
// let tmp = first_word(&s);
// println!("{}", tmp)
// }
// fn first_word(s: &str) -> &str {
// let bytes = s.as_bytes();
// for (i, &item) in bytes.iter().enumerate() {
// if item == b' ' {
// return &s[..i];
// }
// }
// &s[..]
// }
// mod rectangle;
// use std::collections::HashMap;
// fn main() {
// // let s1 = String::from("Hello");
// // let s2 = String::from("World");
// // let s3 = s1 + &s2;
// // println!("{}", s3);
// // // println!("{}", s1);
// // println!("{}", s2);
// let mut scores = HashMap::new();
// scores.insert("blue", 123);
// scores.insert("red", 10);
// scores.entry("yellow").or_insert(20);
// println!("{:?}", scores);
// panic!(":(")
// }
// struct Point<T, U> {
// x: T,
// y: U,
// }
// impl<T, U> Point<T, U> {
// fn mixup<V, W>(self, other: Point<V, W>) -> Point<T, W> {
// Point {
// x: self.x,
// y: other.y,
// }
// }
// }
// fn main() {
// let p1 = Point { x: 1, y: 2 };
// let p2 = Point { x: 'a', y: 'b' };
// let p3 = p1.mixup(p2);
// println!("x:{}, y:{}", p3.x, p3.y);
// println!("x:{}, y:{}", p1.x, p1.y);
// // println!("x:{}, y:{}", p2.x, p2.y);
// }
// use learn_rust::NewsArticle;
// // use learn_rust::Tweet;
// use learn_rust::Summary;
// pub fn notify(item: &impl Summary) {
// println!("{}", item.summarize());
// }
// fn main() {
// let tmp = NewsArticle {
// author: String::from("zj"),
// content: String::from("zj-content"),
// headline: String::from("zj-headline"),
// location: String::from("shenzhen"),
// };
// notify(&tmp)
// }