(self: &mut Self, f: F)
| 17 | } |
| 18 | |
| 19 | fn with<F>(self: &mut Self, f: F) -> io::Result<()> |
| 20 | where |
| 21 | F: Fn(&mut File) -> io::Result<()>, |
| 22 | { |
| 23 | if self.mode == 'w' { |
| 24 | self.file = Some(File::create(&self.filename)?); |
| 25 | f(&mut self.file.as_mut().unwrap())?; |
| 26 | self.file = None; |
| 27 | } |
| 28 | Ok(()) |
| 29 | } |
| 30 | |
| 31 | fn closed(self: &Self) -> bool { |
| 32 | self.file.is_none() |