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 mai
The documentation indicates the issue: the write_fmt method takes one argument, of type std::fmt::Arguments, which can be constructed via the format_args! macro. It also suggests the best way to use it:
The write! macro should be favored to invoke this method instead.
One calls write! (or writeln!) just like println!, but by passing the location to write to as the first argument:
write!(&mut writer, "Factorial of {} = {}", num, factorial);
(Note that the docs have a search bar at the top of each page, so one can find documentation on, for example, macros by searching for there.)