Macro custom_print::write
source · macro_rules! write { ( $macro:path, $writer:expr, expect $(, $($args:tt)*)? ) => { ... }; ( $macro:path, $writer:expr, try $(, $($args:tt)*)? ) => { ... }; }
Expand description
Calls another write macro with the specified writer, arguments and error-handling policy.
It propagates errors if the try
policy is used.
Panics
The macro panics if writing fails and the expect
policy is used.
Examples
use core::fmt::Write;
let mut string = String::new();
assert_eq!(custom_print::write!(writeln, &mut string, expect, "first"), ());
assert_eq!(string, "first\n");
assert_eq!(custom_print::write!(writeln, &mut string, try, "second"), Ok(()));
assert_eq!(string, "first\nsecond\n");