pub struct Provider<'a, T> { /* private fields */ }
Expand description
Creates a binding on demand
T
will be created each time Provider.get()
is called, allowing multiple
instances to be created.
This also prevents creating T
immediately when constructing an object that depends on T
,
which allows lazy initialization and can break cyclic dependency.
WARNING: calling Provider.get()
in a constructor can lead to stackoverflow, and is best
avoided.
If only a single cached instance is needed, consider using Lazy<T>
(Lazy) instead.
Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Provider<'a, T>
impl<'a, T> !RefUnwindSafe for Provider<'a, T>
impl<'a, T> !Send for Provider<'a, T>
impl<'a, T> !Sync for Provider<'a, T>
impl<'a, T> Unpin for Provider<'a, T>
impl<'a, T> !UnwindSafe for Provider<'a, T>
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