Created
June 20, 2018 13:15
-
-
Save panicbit/730c49946eef34e5f93187fee779d369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut head = Node::new(vec[0].clone()); | |
let mut current_head: &mut Node<T> = &mut head; | |
for &next in &vec[1..] { | |
let moved_head = current_head; // Takes the mutable reference away from current_head | |
moved_head.right = Some(Box::new(Node::new(next.clone()))); | |
current_head = moved_head.right.as_mut().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment