Skip to content

Instantly share code, notes, and snippets.

@wakandan
Last active December 23, 2015 21:59
Show Gist options
  • Save wakandan/6699744 to your computer and use it in GitHub Desktop.
Save wakandan/6699744 to your computer and use it in GitHub Desktop.
fn reverse_linkedlist(head: Option<~Node>) -> Option<~Node> {
let mut result = head;
loop {
match result.next {
Some(~node) => {
let old_next = node.next;
node.next = result;
result = old_next;
},
None => {
return result
}
}
}
result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment