std::writeln - Rust
Description: API documentation for the Rust `writeln` macro in crate `std`.
Keywords: rust, rustlang, rust-lang, writeln

# Macro std::writeln [−]

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

Write 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, see `std::fmt`.

# Examples

    use std::io::Write;

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

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

A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects implementing either, as objects do not typically implement both. However, the module must import the traits qualified so their names do not conflict:

    use std::fmt::Write as FmtWrite;
    use std::io::Write as IoWrite;

    let mut s = String::new();
    let mut v = Vec::new();
    writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
    writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
    assert_eq!(v, b"s = \"abc 123\\n\"\n");Run

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)