p0lunin / teloc

Simple, compile-time DI framework for Rust
Apache License 2.0
147 stars 14 forks source link

Respect mutability? #39

Open oriontvv opened 12 months ago

oriontvv commented 12 months ago

Hello, thanks for this crate! I would like to know if it's possible to resolve an mutable instance from ServiceProvider? Or do you consider such feature?

p0lunin commented 12 months ago

Hi, crate isn't intended to be used with mutable references, but you can use interior mutability types (RefMut or Mutex).

Also, you can try to implement mutable references resolving like here but I don't know if borrow checker allows this.