nicolascotton / nject

Simple zero cost dependency injection library made for rust
MIT License
42 stars 3 forks source link

Add factory declaration on provide attribute #30

Closed nicolascotton closed 9 months ago

nicolascotton commented 9 months ago

Proposal:

trait Trait;

#[injectable]
struct Dep;

impl Trait for Dep {}

#[provider]
#[provide(Box<dyn Trait>, |dep: Dep| Box::new(dep))]
struct Provider(#[provide(Rc<dyn Trait>, |x| x.clone())] Rc<dyn Trait>)
nicolascotton commented 9 months ago

34