chassis 0.2.0

Compile-time dependency injection framework
Documentation
use chassis::{AssembleError, AssembleErrors, TypeInfo};

fn errors<T>(res: &Result<T, AssembleErrors>) -> &[AssembleError] {
    match res {
        Ok(_) => &[],
        Err(errors) => errors.as_slice(),
    }
}

#[test]
fn cyclic_dep() {
    pub struct StringArg(String);

    #[derive(Default)]
    pub struct Module;

    #[chassis::module]
    impl Module {
        pub fn cyclic_dep(s: StringArg) -> StringArg {
            StringArg(s.0)
        }
    }

    #[chassis::injector(modules = [Module])]
    pub trait Factory {
        fn resolve(&self) -> StringArg;
    }

    let factory = <dyn Factory>::new();
    let errors = errors(&factory);

    assert_eq!(
        vec![AssembleError::CyclicDependency {
            ty: TypeInfo::of::<StringArg>()
        }],
        errors
    );
}