📚Cheatsheets

Cheatsheet collection for go, rust, python, shell and javascript.

Write string to file

Write string to file path.

use std::io::Write;

fn write_file(content: &String, file_name: &str) {
    let cwd = std::env::current_dir().unwrap();
    let mut file = std::fs::File::create(format!("{}/{}", cwd.to_str().unwrap(), file_name)).unwrap();
    write!(&mut file, "{}", content).unwrap();
}