Skip to content

Instantly share code, notes, and snippets.

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