mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-05-01 18:58:44 +08:00
25 lines
429 B
Rust
25 lines
429 B
Rust
|
struct User {
|
||
|
active: bool,
|
||
|
username: String,
|
||
|
email: String,
|
||
|
sign_in_count: u64,
|
||
|
}
|
||
|
|
||
|
// ANCHOR: here
|
||
|
fn build_user(email: String, username: String) -> User {
|
||
|
User {
|
||
|
email,
|
||
|
username,
|
||
|
active: true,
|
||
|
sign_in_count: 1,
|
||
|
}
|
||
|
}
|
||
|
// ANCHOR_END: here
|
||
|
|
||
|
fn main() {
|
||
|
let user1 = build_user(
|
||
|
String::from("someone@example.com"),
|
||
|
String::from("someusername123"),
|
||
|
);
|
||
|
}
|