Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #[derive(Debug)]
  2. struct Thing {
  3. list: Vec<i32>,
  4. }
  5.  
  6. impl Thing {
  7. fn do_more(&mut self, x: &mut i32) {
  8. *x *= 2;
  9. }
  10. fn do_mut(&mut self, v: i32) {
  11. self.list.push(v);
  12. let x = self.list.last_mut().unwrap();
  13. self.do_more(x);
  14. }
  15. }
  16.  
  17. fn main() {
  18. let mut t = Thing { list: Vec::new() };
  19.  
  20. t.do_mut(1);
  21.  
  22. println!("Done!");
  23. }
Add Comment
Please, Sign In to add comment