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 2057f99

Browse files
structs6.rs
1 parent 6b106ab commit 2057f99

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//You can create instance from other instance with struct update syntax
2+
3+
/*
4+
/ Fill the blank to make the code work
5+
struct User {
6+
active: bool,
7+
username: String,
8+
email: String,
9+
sign_in_count: u64,
10+
}
11+
fn main() {
12+
let u1 = User {
13+
email: String::from("someone@example.com"),
14+
username: String::from("sunface"),
15+
active: true,
16+
sign_in_count: 1,
17+
};
18+
19+
let u2 = set_email(u1);
20+
21+
println!("Success!");
22+
}
23+
24+
fn set_email(u: User) -> User {
25+
User {
26+
email: String::from("contact@im.dev"),
27+
__
28+
}
29+
}
30+
*/

0 commit comments

Comments
(0)

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