Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Created February 22, 2017 21:01
Show Gist options
  • Save mitsuhiko/89501e90ef6fd17023ba1d8ee1b0ce42 to your computer and use it in GitHub Desktop.
Save mitsuhiko/89501e90ef6fd17023ba1d8ee1b0ce42 to your computer and use it in GitHub Desktop.
fn with_file<X: ?Sized, T, F: FnOnce(&mut X) -> T>(&self, f: F) -> T {
if self.options.compress {
f(&mut *self.tempfile.as_ref().unwrap().borrow_mut() as &mut X)
} else {
f(&mut *self.writer.borrow_mut() as &mut X)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment