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 4c9c9a0

Browse files
readme updated
1 parent dcdb1be commit 4c9c9a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎5. Compound Data Types/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,20 @@ struct User {
7474
```
7575

7676
To use a struct after we’ve defined it, we create an instance of that struct by specifying concrete values for each of the fields. We create an instance by stating the name of the struct and then add curly brackets containing <b>key: value pairs</b>, where the keys are the names of the fields and the values are the data we want to store in those fields. We don’t have to specify the fields in the same order in which we declared them in the struct.
77+
78+
```Rust
79+
struct User {
80+
active: bool,
81+
username: String,
82+
email: String,
83+
sign_in_count: u64,
84+
}
85+
fn main() {
86+
let user1 = User {
87+
email: String::from("someone@example.com"),
88+
username: String::from("someusername123"),
89+
active: true,
90+
sign_in_count: 1,
91+
};
92+
}
93+
```

0 commit comments

Comments
(0)

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