Macro core::write1.6.0 [] [src]

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

Write formatted data into a buffer

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(); write!(&mut w, "test").unwrap(); write!(&mut w, "formatted {}", "arguments").unwrap(); assert_eq!(w, b"testformatted arguments"); }
use std::io::Write;

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

assert_eq!(w, b"testformatted arguments");Run