writeln in std - Rust (original) (raw)
Macro writeln
1.0.0 · Source
macro_rules! writeln {
($dst:expr $(,)?) => { ... };
($dst:expr, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span>arg:tt)*) => { ... };
}
Expand description
Writes formatted data into a buffer, with a newline appended.
On all platforms, the newline is the LINE FEED character (\n
/U+000A
) alone (no additional CARRIAGE RETURN (\r
/U+000D
).
For more information, see write!. For information on the format string syntax, seestd::fmt.
§Examples
use std::io::{Write, Result};
fn main() -> Result<()> {
let mut w = Vec::new();
writeln!(&mut w)?;
writeln!(&mut w, "test")?;
writeln!(&mut w, "formatted {}", "arguments")?;
assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
Ok(())
}