Guest User

Untitled

a guest
Sep 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. use std::fs::File;
  2. use std::io::Write;
  3.  
  4. struct Stuff {
  5. file: Option<File>,
  6. }
  7.  
  8. impl Stuff {
  9. fn do_stuff(&mut self) {
  10. let file;
  11. let mut file2 = match self.file.as_ref() {
  12. Some(file) => file,
  13. None => {
  14. file = File::create("temp file").unwrap();
  15. &file
  16. }
  17. };
  18.  
  19. writeln!(file2, "asdf").unwrap();
  20. }
  21. }
Add Comment
Please, Sign In to add comment