Macro inject

Source
macro_rules! inject {
    (
        $(#[$outer:meta])*
        pub struct $Name:ident {
            $($viz:vis $field:ident: $FieldType:ty),*$(,)?
        }
    ) => { ... };
}
Expand description

Syntactic sugar to make a type’s dependencies injectable.

inject!(
    pub struct MyStruct {
        some_component: SomeComponent,
        some_behavior: Arc<dyn SomeBehavior>,
    }
);

Under the hood, this macro implements From<&T> where T: Provides for every field in the struct. If you’d like it to be constructed in a different way, you can manually implement the trait instead of using the macro.