Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concrete mode: There is no way to just generate an implementation for Impl<T>, without also implementing for some T #3

Closed
audunhalland opened this issue Jul 6, 2022 · 2 comments

Comments

@audunhalland
Copy link
Owner

audunhalland commented Jul 6, 2022

This relates to the definition of dependency "leaf nodes".

@audunhalland
Copy link
Owner Author

audunhalland commented Jul 6, 2022

i.e. you have to write

#[entrait(Foo)]
fn foo(deps: &()) -> i32 {
    unimplemented!()
}

which generates a impl<T: Foo> Foo for Impl<T> and a useless, incorrect impl Foo for () which panics.

(assuming you want an implementation for a type that isn't (), but the type you want lives in a downstream crate.)

Maybe this can be referred to as delegating implementation.

The core of the issue seems to be that it appears ridiculous that you annotate a function, but that function ends up not being used. Instead we could just annotate the full trait:

#[implement_for_impl] // <- invent some attribute
trait Foo {
    fn foo(&self) -> i32;
}

@audunhalland audunhalland changed the title There is no way to just generate an implementation for Impl<T>, without also implementing for some T Concrete mode: There is no way to just generate an implementation for Impl<T>, without also implementing for some T Jul 7, 2022
@audunhalland
Copy link
Owner Author

Fixed in 0.4. The solution is to to use an empty #[entrait] attribute on a trait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant