Add example on using structs

This commit is contained in:
laurens 2020-05-22 13:40:09 +02:00
parent 6be18e3e3e
commit 1dfa283017
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#[derive(Debug)]
struct User {
email: String,
username: String,
active: bool,
sign_in_count: u32,
}
fn build_user(email: String, username: String) -> User {
User {
email,
username,
active: true,
sign_in_count: 0,
}
}
fn main() {
let user = build_user(String::from("Heisenberg"), String::from("mail@mail.com"));
println!("Hello to the User: {:?}!", user);
}