Skip to content

Commit cf0dd85

Browse files
committed
Add rust example
1 parent daee6bf commit cf0dd85

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Rust/1-struct.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
struct Date {
2+
year: u32,
3+
month: u32,
4+
day: u32,
5+
}
6+
7+
struct Person {
8+
name: String,
9+
city: String,
10+
born: Date,
11+
}
12+
13+
fn main() {
14+
let p1 = Person {
15+
name: String::from("Marcus"),
16+
city: String::from("Roma"),
17+
born: Date {
18+
day: 26,
19+
month: 4,
20+
year: 121,
21+
},
22+
};
23+
24+
println!(
25+
"Name: {}\nCity: {}\nBorn: {}-{}-{}\n",
26+
p1.name, p1.city, p1.born.year, p1.born.month, p1.born.day
27+
);
28+
}

0 commit comments

Comments
 (0)