Sets the option for truncating a previous file. If a file is successfully opened with this option set it will truncate the file to 0 length if it already exists. The file must be opened with write access for truncate to work. # Examples ```no_run use std::fs::OpenOptions; let file = OpenOptions::new().write(true).truncate(true).open("foo.txt"); ```
(&mut self, truncate: bool)
| 137 | /// let file = OpenOptions::new().write(true).truncate(true).open("foo.txt"); |
| 138 | /// ``` |
| 139 | pub fn truncate(&mut self, truncate: bool) -> &mut OpenOptions { |
| 140 | self.truncate = truncate; self |
| 141 | } |
| 142 | |
| 143 | /// Sets the option for creating a new file. |
| 144 | /// |