Macro try_print::try_print
[−]
[src]
macro_rules! try_print { ($($arg:tt)*) => { ... }; }
Macro for printing to the standard output.
Equivalent to the print!
macro except it does not panic if it fails to
write to stdout.
Note that stdout is frequently line-buffered by default so it may be
necessary to use io::stdout().flush()
to ensure the output is emitted
immediately.
Examples
use std::io::{self, Write}; try_print!("this ").unwrap(); try_print!("will ").unwrap(); try_print!("be ").unwrap(); try_print!("on ").unwrap(); try_print!("the ").unwrap(); try_print!("same ").unwrap(); try_print!("line ").unwrap(); io::stdout().flush().unwrap(); try_print!("this string has a newline, why not choose println! instead?\n").unwrap(); io::stdout().flush().unwrap();