Skip to content

Support #[autoimpl] for traits with non-generic targets - #65

Merged
dhardy merged 4 commits into
masterfrom
push-vmlkyolwxrmo
Jun 10, 2026
Merged

Support #[autoimpl] for traits with non-generic targets#65
dhardy merged 4 commits into
masterfrom
push-vmlkyolwxrmo

Conversation

@dhardy

@dhardy dhardy commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

This allows some (possibly rather useless) impls like this:

struct MyVec {
    vec: Vec<()>,
}

#[autoimpl(for MyVec using self.vec)]
trait IsEmpty {
    fn is_empty(&self) -> bool;
}

impl<T> IsEmpty for Vec<T> {
    fn is_empty(&self) -> bool {
        Vec::is_empty(self)
    }
}

Of course, this should be done using #[autoimpl(IsEmpty using self.vec)] on struct MyVec, but without writing a custom extension to impl-tools-lib specifically for the IsEmpty trait that isn't possible.

@dhardy
dhardy merged commit 5116f31 into master Jun 10, 2026
5 checks passed
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 this pull request may close these issues.

1 participant