macro_rules! register_provider {
    ($provider:expr) => { ... };
}
Available on crate feature auto-register only.
Expand description

Register a Provider that will be collected by auto_registered_providers.

If you have:

Then you don’t need to use this macro to register Provider.

But if you use function define a Provider and you want to use auto-registration, then you need to use this macro.

§Example

use rudi::{register_provider, singleton, Context, Provider};

fn foo() -> Provider<&'static str> {
    singleton(|_| "Hello").into()
}

register_provider!(foo());

fn main() {
    let mut cx = Context::auto_register();
    assert!(cx.resolve_option::<&'static str>().is_some());
}