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

Add support for generics on the derived type #6

Closed
bobozaur opened this issue Feb 23, 2023 · 0 comments · Fixed by #10
Closed

Add support for generics on the derived type #6

bobozaur opened this issue Feb 23, 2023 · 0 comments · Fixed by #10

Comments

@bobozaur
Copy link
Owner

Might be worth adding some sort of mechanism for applying a transition only for a certain set of the derived type generics OR some trait bounds (that would match the From impl affecting the derived type).

Example of the desired behavior:

#[derive(TransitiveFrom)]
#[transitive(into(B, C, D)] // only for A<u8>
#[transitive(into(E, F, G, H)] // only for A<T: AsRef<str>>
pub struct A<T>(T); 

impl From<A<u8>> for B {...}

impl<T> From<A<T>> for E 
where T: AsRef<str> {...}

Still no idea on what notation to use and how to organize this in the attribute.
Ideally, these constraints should be applied per transition path, as otherwise the same conflicts would arise as in previous versions.

Perhaps the attribute could be modified like this:
#[transitive(into(path(B, C, D), generics(u8), bound("T: AsRef<str>"))]

Generics would get resolved in order if provided and any left overs, if any, would have to be constrained by the trait bounds if necessary.
"name = value" pairs might be a better idea though.

@bobozaur bobozaur linked a pull request Feb 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant