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 5bafff2

Browse files
readme updated
1 parent 4c9c9a0 commit 5bafff2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎5. Compound Data Types/readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,24 @@ fn main() {
9191
};
9292
}
9393
```
94+
95+
To get a specific value from a struct, we use dot notation. For example, to access this user’s email address, we use user1.email. If the instance is mutable, we can change a value by using the dot notation and assigning into a particular field.<br>
96+
97+
```Rust
98+
struct User {
99+
active: bool,
100+
username: String,
101+
email: String,
102+
sign_in_count: u64,
103+
}
104+
fn main() {
105+
let mut user1 = User {
106+
email: String::from("someone@example.com"),
107+
username: String::from("someusername123"),
108+
active: true,
109+
sign_in_count: 1,
110+
};
111+
112+
user1.email = String::from("anotheremail@example.com");
113+
}
114+
```

0 commit comments

Comments
(0)

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