Macro custom_print::define_try_print
source · macro_rules! define_try_print { ( $( #[$meta:meta] )* $name:ident, $( $args:tt )* ) => { ... }; }
Expand description
Defines try_print
macro that defines a fallible print macro that uses the specified writer.
The first argument specifies the generated macro name.
The writer itself is specified by the rest arguments with the define_writer
macros.
See also define_print
and define_try_println
macros.
Examples
let mut string = String::new();
custom_print::define_try_print!(try_print, fmt, |value: &str| string += value);
assert_eq!(try_print!("value"), Ok(()));
assert_eq!(string, "value");