pub fn write_to_file<L: AsRef<str>>(
lines: impl IntoIterator<Item = L>,
destination: &StreamIdent,
) -> Result<()>Expand description
Writes a list of strings to a file;
one per line.
See also: [create_output_writer]
§Example
use cli_utils_hoijui::StreamIdent;
use cli_utils_hoijui::write_to_file;
let lines = vec!["line 1", "line 2", "line 3"];
let out_stream_ident = StreamIdent::StdOut; // writes to stdout
write_to_file(&lines, &out_stream_ident)?;
let out_stream_ident = StreamIdent::Path(PathBuf::from("my_dir/my_file.txt"), false); // writes to file "$CWD/my_dir/my_file.txt"
write_to_file(&lines, &out_stream_ident)?;§Errors
If writing to destination failed.