Skip to main content

write_line_to_fmt

Function write_line_to_fmt 

Source
pub fn write_line_to_fmt(
    out: &mut impl Write,
    args: Arguments<'_>,
) -> Result<()>
Expand description

Writes formatted content + pure LF via Write::write_fmt (G-MAC-01).

Call with format_args!(...) to avoid format! → temporary Stringwrite_all double work. Same LF + flush contract as write_line_to.

§Examples

use ssh_cli::output::write_line_to_fmt;
use std::io::Cursor;

let mut buf = Cursor::new(Vec::new());
let name = "lab";
write_line_to_fmt(&mut buf, format_args!("host={name}")).unwrap();
assert_eq!(String::from_utf8(buf.into_inner()).unwrap(), "host=lab\n");

§Errors

Propagates I/O errors from the underlying writer (including BrokenPipe).