Skip to content

Instantly share code, notes, and snippets.

@ezyang
Created December 17, 2013 03:30
Show Gist options
  • Save ezyang/7999613 to your computer and use it in GitHub Desktop.
Save ezyang/7999613 to your computer and use it in GitHub Desktop.
fn pop<T>(prev: &mut ~List<T>) -> Option<~List<T>> {
let xs = util::replace(match prev {
&~Cons(_, ref mut rs) => rs,
&~Nil => return None
}, ~Nil);
Some(util::replace(prev, xs))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment