struct Config { port: u32, } trait DAL {} struct PostgresDAL; impl DAL for PostgresDAL {} struct Service { dal: D, } impl Service { fn new(port: u32, dal: D) -> Self { println!("Impl trait service started on port {}", port); Self { dal } } } #[despatma_dependency_container::dependency_container] impl DependencyContainer { fn config(&self) -> Config { Config { port: 8080 } } #[Transient(PostgresDAL)] fn dal(&self) -> impl DAL { PostgresDAL } fn service(&self, config: Config, dal: impl DAL) -> Service { Service::new(config.port, dal) } } fn main() { let container = DependencyContainer::new(); let _service = container.service(); }