Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. struct User {
  2. username: String,
  3. email: String,
  4. sign_in_count: u64,
  5. active: bool,
  6. }
  7.  
  8. struct UserWithRefs {
  9. username: &str,
  10. email: &str,
  11. sign_in_count: u64,
  12. active: bool,
  13. }
  14.  
  15. // tuple structs
  16. struct Color(i32, i32, i32);
  17. struct Point(i32, i32, i32);
  18.  
  19. // unit struct
  20. struct Identity();
  21.  
  22. fn build_user(email: String, username: String) -> User{
  23. /*
  24. User {
  25. email: email,
  26. username: username,
  27. active: true,
  28. sign_in_count: 1,
  29. }
  30. */
  31. User {
  32. email,
  33. username,
  34. active: true,
  35. sign_in_count: 1,
  36. }
  37. }
  38.  
  39. fn main(){
  40. println!("who who?");
  41. /*
  42. let mut user1 = User {
  43. email: String::from("digbick@mothail.com"),
  44. username: String::from("someomseir"),
  45. active: true,
  46. sign_in_count: 1,
  47. };
  48. */
  49. let mut user1 = build_user( String::from("digbick@mothail.com"),String::from("someomseir") );
  50.  
  51. user1.email = String::from("hahahfuckoff@hotmail.com");
  52.  
  53. /*
  54. let user2 = User {
  55. email: String::from("another@hotmail.com"),
  56. username: String::from("anotherassoile"),
  57. active: user1.active,
  58. sign_in_count: user1.sign_in_count,
  59. };
  60. */
  61.  
  62. let user2 = User {
  63. email: String::from("another@hotmail.com"),
  64. username: String::from("anotherassoile"),
  65. ..user1
  66. };
  67.  
  68. /*
  69. for item in user1 {
  70. println!("item: {}", item);
  71. }
  72. */
  73.  
  74. let black = Color(0,0,0);
  75. let origin = Point(0,0,0);
  76.  
  77. let idem = Identity();
  78.  
  79. let user3 = UserWithRefs {
  80. email: user2.email,
  81. username: user3.username,
  82. ..user1
  83. };
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement