Struct lockjaw::Provider [−][src]
pub struct Provider<'a, T> { /* fields omitted */ }
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.