audunhalland / entrait

Loosely coupled Rust application design made easy
86 stars 3 forks source link

`#[entrait_impl] mod {}` should just be replaced by an impl block #14

Closed audunhalland closed 2 years ago

audunhalland commented 2 years ago

Instead of

#[entrait_impl]
mod some_mod {
    #[derive_impl(super::SomeTrait)]
    pub struct SomeType;
}

The macro should instead work with:

pub struct SomeType;

#[entrait_impl] // ?
impl SomeTrait for SomeType {
    fn foo(deps: &impl SomethingElse) {}
}

which would expand to:

impl SomeType { // <--- removed "SomeTrait for" from this location
    fn foo(deps: &impl SomethingElse) {}
}
impl<T> SomeTrait<T> for SomeType { // <--- move into this place
    fn foo(__impl: &Impl<T>) {
        Self::foo(__impl)
    }
}