-
Notifications
You must be signed in to change notification settings - Fork 215
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 derive macro for BuilderLite
, add #[non_exhaustive]
to some enums and structs
#2614
Conversation
Very nice! Just the generated docs look a bit off: // Recursive expansion of procmacros::BuilderLite macro
// =====================================================
#[automatically_derived]
impl Config {
#[doc = r" Assign the given value to the `#field_ident` field."]
pub fn with_frequency(mut self, frequency: HertzU32) -> Self {
self.frequency = frequency;
self
}
#[doc = r" Assign the given value to the `#field_ident` field."]
pub fn with_timeout(mut self, timeout: u32) -> Self {
self.timeout = Some(timeout);
self
}
} |
Ahh oops, guess that didn't work how I expected it to 😅 Will fix, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
86260ad
to
fa2d7ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Maybe this PR could also apply it to |
This is working towards #2500.
First, I've created a derive procmacro to implement the Builder Lite pattern on a struct automatically. Definitely not an expert on procmacros, so welcome to hear any feedback here, but seems to be working at least.
Additionally, I've started adding
#[non_exhaustive]
to public enums and structs where necessary, starting with the core peripherals which we are looking to stabilize in our1.x.x.
release. Based on comments in the GPIO analysis issue, it is not clear that any of these are currently required there, but let me know if this is incorrect. Additionally, if you feel any of these attributes are missing in the included drivers, or that any which I've added are not necessary, please let me know.Once this is merged I will continue to work on adding these to other drivers, just wanted to prove this out first with a limited subset.