Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #![feature(nll)]
  2. #![allow(dead_code)]
  3.  
  4. struct List {
  5. next: Option<Box<List>>,
  6. }
  7.  
  8. impl List {
  9. fn walk_the_list(&mut self) {
  10. let mut current = self;
  11. loop {
  12. match current.next {
  13. None => return,
  14. Some(ref mut inner) => current = inner,
  15. }
  16. }
  17. }
  18.  
  19. fn consume_the_list(mut self) {
  20. self.walk_the_list();
  21. }
  22. }
  23.  
  24. fn main() {}
Add Comment
Please, Sign In to add comment