Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22a5e30

Browse files
structs4.rs completed
1 parent 88d2ee7 commit 22a5e30

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
508 KB
Binary file not shown.

‎5. Compound Data Types/5.5 Structs/structs4.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ fn main() {
2323
println!("Success!");
2424
}
2525
*/
26+
// Fill the blank and fix the error without adding/removing new line
27+
struct Person {
28+
name: String,
29+
age: u8,
30+
}
31+
fn main() {
32+
let age = 18;
33+
let mut p = Person {
34+
name: String::from("sunface"),
35+
age,
36+
};
37+
38+
// How can you believe sunface is only 18?
39+
p.age = 30;
40+
41+
// Fill the blank
42+
p.name = String::from("sunfei");
43+
44+
println!("Success!");
45+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /