Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fs::File;
- use std::io::Write;
- struct Stuff {
- file: Option<File>,
- }
- impl Stuff {
- fn do_stuff(&mut self) {
- let file;
- let mut file2 = match self.file.as_ref() {
- Some(file) => file,
- None => {
- file = File::create("temp file").unwrap();
- &file
- }
- };
- writeln!(file2, "asdf").unwrap();
- }
- }
Add Comment
Please, Sign In to add comment