Struct dyn_inject::registry::Registry
source · pub struct Registry { /* private fields */ }
Expand description
A registry is a container for type-erased structs. It can store
any struct, or any dyn Trait
object, which can then be queried again by calling
get::<T>()
for a regular struct or get_dyn::<dyn Trait>()
for trait objects.
Implementations§
source§impl Registry
impl Registry
sourcepub fn put<T: 'static>(&mut self, item: T)
pub fn put<T: 'static>(&mut self, item: T)
Put a static type T
into the registry. This can then be retrieved back
by calling Self::get::<T>()
sourcepub fn put_dyn<T: ?Sized + 'static>(&mut self, item: impl Unsize<T>)
pub fn put_dyn<T: ?Sized + 'static>(&mut self, item: impl Unsize<T>)
Put a trait object into the registry. If called with dyn MyTrait
, this takes in
any Foo: MyTrait
, which is then moved into the registry and can be queried back with
Self::get_dyn::<dyn MyTrait>()
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !Send for Registry
impl !Sync for Registry
impl !Unpin for Registry
impl !UnwindSafe for Registry
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