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 Trait
s
easier, by hiding their details.
A “dyn newtype” Deref
s to the underlying &dyn Trait
, making
it easy to access the encapsulated operations, while hiding
the boxing details.