create file in a loop which writes numbers from 1 to 10 in every line in rust

main.rs
use std::fs::File;
use std::io::Write;

fn main() {
    for i in 1..=10 {
        let mut file = File::create(format!("output{}.txt", i)).expect("Unable to create file");
        writeln!(file, "{}", i).expect("Unable to write to file");
    }
}
246 chars
10 lines

related categories

gistlibby LogSnag