extern crate he_di; #[macro_use] extern crate he_di_derive; trait Foo { fn foo(&self) -> String; } #[derive(Component)] #[interface(Foo)] struct FooImpl { name: String, } impl Foo for FooImpl { fn foo(&self) -> String { self.name.clone() } } #[test] fn container_module_doc_example_1() { let mut builder = he_di::ContainerBuilder::new(); // Register `FooImpl` as a `Foo` Component builder .register::() .as_type::(); let mut container = builder.build().unwrap(); let foo = container .with_named_parameter::("name", "fooooooo".to_string()) // .with_typed_parameter::("fooooooo".to_string()) .resolve::() .unwrap(); assert_eq!(foo.foo(), "fooooooo".to_string()); } #[test] fn container_module_doc_example_2() { let mut builder = he_di::ContainerBuilder::new(); // Register `FooImpl` as a `Foo` Component builder .register::() .as_type::() .with_named_parameter("name", "fooooo".to_string()); // .with_type_parameter::("fooooo".to_string()); // alternative // etc }