Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct User {
- username: String,
- email: String,
- sign_in_count: u64,
- active: bool,
- }
- struct UserWithRefs {
- username: &str,
- email: &str,
- sign_in_count: u64,
- active: bool,
- }
- // tuple structs
- struct Color(i32, i32, i32);
- struct Point(i32, i32, i32);
- // unit struct
- struct Identity();
- fn build_user(email: String, username: String) -> User{
- /*
- User {
- email: email,
- username: username,
- active: true,
- sign_in_count: 1,
- }
- */
- User {
- email,
- username,
- active: true,
- sign_in_count: 1,
- }
- }
- fn main(){
- println!("who who?");
- /*
- let mut user1 = User {
- email: String::from("digbick@mothail.com"),
- username: String::from("someomseir"),
- active: true,
- sign_in_count: 1,
- };
- */
- let mut user1 = build_user( String::from("digbick@mothail.com"),String::from("someomseir") );
- user1.email = String::from("hahahfuckoff@hotmail.com");
- /*
- let user2 = User {
- email: String::from("another@hotmail.com"),
- username: String::from("anotherassoile"),
- active: user1.active,
- sign_in_count: user1.sign_in_count,
- };
- */
- let user2 = User {
- email: String::from("another@hotmail.com"),
- username: String::from("anotherassoile"),
- ..user1
- };
- /*
- for item in user1 {
- println!("item: {}", item);
- }
- */
- let black = Color(0,0,0);
- let origin = Point(0,0,0);
- let idem = Identity();
- let user3 = UserWithRefs {
- email: user2.email,
- username: user3.username,
- ..user1
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement