macro_rules! build_unwind_context_data {
( fn $name:ident ( $( $args:tt )* ) ) => { ... };
( fn $name:literal ( $( $args:tt )* ) ) => { ... };
( fn ( $( $args:tt )* ) ) => { ... };
( $( $vars:tt )* ) => { ... };
}Expand description
Creates either UnwindContextFunc or UnwindContextArgs wrapper with
the given function arguments or scope variables.
Passed 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.
There are three forms of this macro:
- Create
UnwindContextFuncwith an automatically determined function name and the given attributes as function attributes. The arguments do not have to be the real function arguments.
use unwind_context::build_unwind_context_data;
fn func(a: u32, b: String, c: bool) {
let _data = build_unwind_context_data!(fn());
let _data = build_unwind_context_data!(fn(a, &b, c));
let _data = build_unwind_context_data!(fn(a, b.clone(), c));
let _data = build_unwind_context_data!(fn(..., c));
let _data = build_unwind_context_data!(fn(a, ...));
let _data = build_unwind_context_data!(fn(a, ..., c));
let _data = build_unwind_context_data!(fn(a, &b, c, "step 1"));
// ...
}- Create
UnwindContextFuncwith a specific function names and the given attributes as function attributes. Note that only ident-like function names are supported is unquoted. Path names should be enclosed in quotes. The arguments do not have to be the real function arguments.
use unwind_context::build_unwind_context_data;
fn func(a: u32, b: String, c: bool) {
let _data = build_unwind_context_data!(fn func());
let _data = build_unwind_context_data!(fn func(a, &b, c));
let _data = build_unwind_context_data!(fn func(a, b.clone(), c));
let _data = build_unwind_context_data!(fn func(..., c));
let _data = build_unwind_context_data!(fn func(a, ...));
let _data = build_unwind_context_data!(fn func(a, ..., c));
let _data = build_unwind_context_data!(fn func(a, &b, c, "step 1"));
let _data = build_unwind_context_data!(fn "func"());
let _data = build_unwind_context_data!(fn "mod1::mod2::func"());
let _data = build_unwind_context_data!(fn "mod1::mod2::func"(a, &b, c));
// ...
}- Create
UnwindContextArgswith the given scope attributes.
use unwind_context::build_unwind_context_data;
fn func(a: u32) {
let b = a.to_string();
let c = a > 100;
let _data = build_unwind_context_data!(a, &b, c);
let _data = build_unwind_context_data!(a, b.clone(), c);
let _data = build_unwind_context_data!(..., c);
let _data = build_unwind_context_data!(a, ...);
let _data = build_unwind_context_data!(a, ..., c);
let _data = build_unwind_context_data!(a, &b, c, "step 1");
// ...
}