std::writeln! []

macro_rules! writeln {
    ( $ dst : expr , $ fmt : expr ) => { ... };
    (
$ dst : expr , $ fmt : expr , $ ( $ arg : tt ) * ) => { ... };
}

Write formatted data into a buffer, with appending a newline.

On all platforms, the newline is the LINE FEED character (\n/U+000A) alone (no additional CARRIAGE RETURN (\r/U+000D).

This macro accepts any value with write_fmt method as a writer, a format string, and a list of arguments to format.

write_fmt method usually comes from an implementation of std::fmt::Write or std::io::Write traits. These are sometimes called 'writers'.

Passed arguments will be formatted according to the specified format string and the resulting string will be passed to the writer.

See std::fmt for more information on format syntax.

Return value is completely dependent on the 'write_fmt' method.

Common return values are: Result, io::Result

Examples

fn main() { use std::io::Write; let mut w = Vec::new(); writeln!(&mut w, "test").unwrap(); writeln!(&mut w, "formatted {}", "arguments").unwrap(); assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes()); }
use std::io::Write;

let mut w = Vec::new();
writeln!(&mut w, "test").unwrap();
writeln!(&mut w, "formatted {}", "arguments").unwrap();

assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes());