Guest User

Untitled

a guest
Jan 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. struct Part1 {
  2. points: u32
  3. }
  4.  
  5. impl Part1 {
  6. fn new() -> Part1 {
  7. Part1 { points: 30 }
  8. }
  9.  
  10. fn points<'a>(&'a mut self, points: u32) -> &'a mut Self {
  11. self.points = points;
  12. self
  13. }
  14.  
  15. fn run(&self) {
  16. println!("{:?}", self.points);
  17. }
  18. }
  19.  
  20. fn main() {
  21. let mut p = Part1::new().points(11);
  22. p.run();
  23.  
  24. p.points(5);
  25. p.run();
  26. }
Add Comment
Please, Sign In to add comment