macro_rules! unwind_context_with_fmt {
(
( $( $context:tt )* )
, writer = $writer:expr
, panic_detector = $panic_detector:expr
$(, color_scheme = $color_scheme:expr )?
$(,)?
) => { ... };
}Expand description
Creates UnwindContextWithFmt with a given core::fmt::Write writer,
panic detector, color scheme, and a given function or scope context.
If not specified it uses get_default_color_scheme_if_enabled as a
default color scheme.
The returned unwind context scope guard value should be kept alive as long
as unwind context is needed. If unused, the UnwindContextWithFmt will
immediately drop.
Passed context arguments are lazily formatted. The created wrapper takes
ownership of the given arguments, so it may be necessary to use value
references, clones, or pass the pre-prepared string representation. It also
supports the ... placeholder to show that some values have been omitted.
For more information about context argument, see
build_unwind_context_data.
ยงExamples
use unwind_context::unwind_context_with_fmt;
fn example1(foo: u32, bar: &str, secret: &str, custom_writer: &mut String) {
let _ctx = unwind_context_with_fmt!(
(fn(foo, bar, ...)),
writer = custom_writer,
panic_detector = unwind_context::StdPanicDetector,
color_scheme = None,
);
// ...
}use unwind_context::{unwind_context_with_fmt, AnsiColorScheme};
fn example2<W: core::fmt::Write, P: unwind_context::PanicDetector>(
foo: u32,
bar: &str,
custom_writer: &mut W,
custom_panic_detector: P,
custom_color_scheme: &'static AnsiColorScheme,
) {
let _ctx = unwind_context_with_fmt!(
(fn(foo, bar)),
writer = custom_writer,
panic_detector = custom_panic_detector,
color_scheme = Some(custom_color_scheme),
);
// ...
}