I want to write output of my function to a file. I expected that write_fmt
is what I require:
use std::{
fs::File,
io::{BufWriter, Write},
};
fn main() {
let write_file = File::create("/tmp/output").unwrap();
let mut writer = BufWriter::new(&write_file);
// From my function
let num = 1;
let factorial = 1;
writer.write_fmt("Factorial of {} = {}", num, factorial);
}
Error
error[E0061]: this function takes 1 parameter but 3 parameters were supplied
--> src/main.rs:11:12
|
11 | writer.write_fmt("Factorial of {} = {}", num, factorial);
| ^^^^^^^^^ expected 1 parameter
This seems wrong and there isn't much available in the documentation.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…