構造体を可変変数に入れてフィールドを書き換える
2022/2/18 0:58:00
struct User {
username: String,
email: String,
sign_in_count: u64,
active: bool,
}
fn main() {
let mut user1 = User {
username: String::from("username1"),
email: String::from("[email protected]"),
active: true,
sign_in_count: 1,
};
user1.username = String::from("username2");
println!("{}", user1.username); //username2
}