macro_rules! impl_provider {
($trait_name:ident) => { ... };
}Expand description
Macro to generate Requires<T> trait implementations for
MountainEnvironment.
This macro takes a trait name and generates an implementation of
Requires<dyn Trait> for MountainEnvironment. The implementation returns
Arc::new(self.clone()), which is the standard pattern for the DI
container.
§Arguments
$trait_name- The name of the trait (withoutdynprefix)
§Example
ⓘ
impl_provider!(CommandExecutor);Expands to:
ⓘ
impl Requires<dyn CommandExecutor> for MountainEnvironment {
fn Require(&self) -> Arc<dyn CommandExecutor> {
Arc::new(self.clone())
}
}§Note
This macro is intended to be used within MountainEnvironment.rs after the
MountainEnvironment struct definition. The macro assumes that
MountainEnvironment implements all the traits that are being requested.