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 basic handling for generics in derive macro #41

Merged
merged 2 commits into from
Oct 20, 2020

Conversation

MrJohz
Copy link
Contributor

@MrJohz MrJohz commented Oct 17, 2020

This is pretty simple, I've tried to do the bare minimum to get things working, rather than make things too complex, but it solves my initial use-case, and making future changes with generics should be a simple additive process when new use-cases are found.

We basically pull the type params out of the generics object (i.e. not the lifetimes, and not any const parameters either), and, if there are any, create a where-clause of T: ::ramhorns::Content for each type param (i.e. T) that has been declared.

There are probably improvements that could be made, such as not adding the type bound if the ramhorns(skip) attribute is used for that field, or copying over other type bounds that exist, but I figure they can be added later if they are likely to actually be useful to someone.

Closes #38

@maciejhirsz
Copy link
Owner

Cheers! I'd like this to at least support user defined trait bounds too to make a release, which might require a bit more code. Will try to do that over the weekend.

@maciejhirsz maciejhirsz merged commit e06efe1 into maciejhirsz:master Oct 20, 2020
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.

Generic type bounds are not handled
2 participants