diff options
| author | Árni Dagur <agudmundsson@fc-md.umd.edu> | 2020-03-30 00:14:54 -0400 |
|---|---|---|
| committer | Árni Dagur <agudmundsson@fc-md.umd.edu> | 2020-03-30 00:14:54 -0400 |
| commit | 0b289bc528aca9415802cbf069c55106d8d8f6d2 (patch) | |
| tree | afe4aa67f73c371a3b94e7aac1a32679f3c32480 | |
| parent | ec193aa9d973b3b7e0a7f5a4d771239c5f00ed21 (diff) | |
Always create new file in 'serialize_to_file'
| -rw-r--r-- | src/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -198,7 +198,10 @@ impl Engine { | |||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()> { | 200 | pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()> { |
| 201 | let mut fd = fs::File::open(file)?; | 201 | let mut fd = fs::OpenOptions::new() |
| 202 | .create_new(true) | ||
| 203 | .write(true) | ||
| 204 | .open(file)?; | ||
| 202 | let data = self.serialize()?; | 205 | let data = self.serialize()?; |
| 203 | fd.write_all(&data)?; | 206 | fd.write_all(&data)?; |
| 204 | Ok(()) | 207 | Ok(()) |
