fedimint_core

Macro dyn_newtype_define

Source
macro_rules! dyn_newtype_define {
    (   $(#[$outer:meta])*
        $vis:vis $name:ident<$lifetime:lifetime>(Box<$trait:ident>)
    ) => { ... };
    (   $(#[$outer:meta])*
        $vis:vis $name:ident(Box<$trait:ident>)
    ) => { ... };
    (   $(#[$outer:meta])*
        $vis:vis $name:ident<$lifetime:lifetime>(Arc<$trait:ident>)
    ) => { ... };
    (   $(#[$outer:meta])*
        $vis:vis $name:ident(Arc<$trait:ident>)
    ) => { ... };
}
Expand description

Define “dyn newtype” (a newtype over dyn Trait)

This is a simple pattern that make working with dyn Traits easier, by hiding their details.

A “dyn newtype” Derefs to the underlying &dyn Trait, making it easy to access the encapsulated operations, while hiding the boxing details.