Skip to main content

Crate dyn_shim

Crate dyn_shim 

Source
Expand description

Generate a dyn-compatible shim trait and blanket impl from a source trait that is not dyn-compatible.

Some traits are not dyn-compatible, so you cannot hold a mixed set of implementors behind one Box<dyn Trait>. The dyn_shim attribute reads the trait it is applied to, builds a second trait containing only the dyn-compatible subset, and forwards each call to the original. Every implementor of the source trait then works as a dyn shim.

See dyn_shim for an example, which methods are forwarded, and the limitations.

Attribute Macrosยง

dyn_shim
Generate a dyn-compatible shim for the annotated trait.