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

derive: properly handle generic structs and enums #125

Merged
merged 5 commits into from
Aug 18, 2020
Merged

Conversation

japaric
Copy link
Member

@japaric japaric commented Aug 18, 2020

closes #124

suggestions for test cases are welcome

@japaric japaric added this to the 0.1.0-alpha milestone Aug 18, 2020
Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a test that uses lifetime parameters and lifetimes in the where-clause?

// `Format` bounds for non-native field types
let mut preds = field_types
.into_iter()
.map(|ty| quote!(#ty: defmt::Format))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so this creates bounds for each field's type, which is different from what the built-in custom derives are doing (which is adding bounds to each type parameter rust-lang/rust#26925). This is more correct, but I wonder if we should document it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't hurt to document it!

firmware/qemu/src/bin/log.rs Outdated Show resolved Hide resolved
firmware/qemu/src/bin/log.rs Outdated Show resolved Hide resolved
@jonas-schievink jonas-schievink merged commit ef8046a into main Aug 18, 2020
@jonas-schievink jonas-schievink deleted the gh124 branch August 18, 2020 16:27
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.

derive: generic structs (and enums?) are not supported
2 participants