#[non_exhaustive]pub struct RegistrationFunc(/* private fields */);Expand description
All auto-registration functions need to use this type for registration.
This is, usually, used by the derive macro, and not manually.
Implementations§
Source§impl RegistrationFunc
impl RegistrationFunc
Sourcepub const fn new(register: fn(&Registry)) -> Self
pub const fn new(register: fn(&Registry)) -> Self
Create a new RegistrationFunc from a register function.
The register function gets passed a Registry, which it must use to
register one or more types.
The function must not have any side-effects. It may be called concurrently, in parallel, and from any thread (not only the main thread).
§Example
#[derive(Debug)]
struct StringTemplate {
template: &'static str,
}
// Usually, this `impl` is generated by the `Inject` proc-macro.
impl StringTemplate {
pub(crate) fn register(registry: &Registry) {
registry
.register_transient::<StringTemplate, _>(|| StringTemplate { template: "" });
}
}
// The construction must be `const`.
autoregister!(RegistrationFunc::new(
StringTemplate::register
));Trait Implementations§
Source§impl Debug for RegistrationFunc
impl Debug for RegistrationFunc
impl Collect for RegistrationFunc
Auto Trait Implementations§
impl Freeze for RegistrationFunc
impl RefUnwindSafe for RegistrationFunc
impl Send for RegistrationFunc
impl Sync for RegistrationFunc
impl Unpin for RegistrationFunc
impl UnwindSafe for RegistrationFunc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more