Add support for dependencies of dependencies

This commit is contained in:
Diggory Blake 2019-04-02 17:16:33 +01:00
parent f47d3a417d
commit cc46fbe621
4 changed files with 43 additions and 12 deletions

View file

@ -52,7 +52,7 @@
//! struct StdoutLoggerFactory;
//! impl aerosol::Factory for StdoutLoggerFactory {
//! type Object = Arc<Logger>;
//! fn build() -> Result<Arc<Logger>, failure::Error> {
//! fn build(_: ()) -> Result<Arc<Logger>, failure::Error> {
//! Ok(Arc::new(StdoutLogger))
//! }
//! }
@ -116,9 +116,9 @@ pub trait Provide<T> {
/// Implement this trait to provide a convenient syntax for
/// constructing implementations of dependencies.
pub trait Factory {
pub trait Factory<Args=()> {
type Object;
fn build() -> Result<Self::Object, failure::Error>;
fn build(args: Args) -> Result<Self::Object, failure::Error>;
}
/// Allows cloning a context whilst replacing one dependency