macro_rules! wrap_life_span_handler {
($ vis : vis struct $ name : ident ; impl LifeSpanHandler { $ ($ (# [$ attrs_name : meta]) * fn $ method_name : ident (& $ self : ident $ (, $ arg_name : ident : $ arg_type : ty) * $ (,) ?) $ (-> $ return_type : ty) ? { $ ($ body : tt) * }) * }) => { ... };
($ vis : vis struct $ name : ident $ (< $ ($ generic_type : ident : $ first_generic_type_bound : tt $ (+ $ generic_type_bound : tt) *) , + $ (,) ? >) ? { $ ($ field_vis : vis $ field_name : ident : $ field_type : ty) , * $ (,) ? } impl LifeSpanHandler { $ ($ (# [$ attrs_name : meta]) * fn $ method_name : ident (& $ self : ident $ (, $ arg_name : ident : $ arg_type : ty) * $ (,) ?) $ (-> $ return_type : ty) ? { $ ($ body : tt) * }) * }) => { ... };
}Expand description
Implement the WrapLifeSpanHandler trait for the specified struct. You can declare more
members for your struct, and in the impl LifeSpanHandler block you can override default
methods implemented by the ImplLifeSpanHandler trait.
ยงExample
wrap_life_span_handler! {
struct MyLifeSpanHandler {
payload: String,
}
impl LifeSpanHandler {
// ...
}
}
fn make_my_struct() -> LifeSpanHandler {
MyLifeSpanHandler::new("payload".to_string())
}