Movatterモバイル変換


[0]ホーム

URL:


println

std

Macroprintln 

1.0.0 ·Source
macro_rules! println {    () => { ... };    ($($arg:tt)*) => { ... };}
Expand description

Prints to the standard output, with 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 uses the same syntax asformat!, but writes to the standard output instead.Seestd::fmt for more information.

Theprintln! macro will lock the standard output on each call. If you callprintln! within a hot loop, this behavior may be the bottleneck of the loop.To avoid this, lock stdout withio::stdout().lock():

usestd::io::{stdout, Write};letmutlock = stdout().lock();writeln!(lock,"hello world").unwrap();

Useprintln! only for the primary output of your program. Useeprintln! instead to print error and progress messages.

See the formatting documentation instd::fmtfor details of the macro argument syntax.

§Panics

Panics if writing toio::stdout fails.

Writing to non-blocking stdout can cause an error, which will leadthis macro to panic.

§Examples

println!();// prints just a newlineprintln!("hello there!");println!("format {} arguments","some");letlocal_variable ="some";println!("format {local_variable} arguments");

[8]ページ先頭

©2009-2026 Movatter.jp