Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Append to file

  • append
  • open
use std::fs::File;
use std::io::Write;

fn main() {
    let filename = "data.txt";
    let mut fh = match File::options().append(true).open(filename) {
        Ok(fh) => fh,
        Err(_) => File::create(filename).unwrap(),
    };
    writeln!(&mut fh, "Hello").unwrap();
}