let mut write = OpenOptions::new() .write(true) .truncate(true) .open("filename") .expect("Unable to open file"); write .write_all("data".as_bytes()) .expect("Unable to write data");