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 field defaults to proc-macro frontend #1560

Merged
merged 2 commits into from
May 25, 2023

Conversation

jplatte
Copy link
Collaborator

@jplatte jplatte commented May 25, 2023

Based on #1559.

@jplatte jplatte changed the title Add support for fields defaults to proc-macro frontend Add support for field defaults to proc-macro frontend May 25, 2023
@jplatte jplatte force-pushed the jplatte/record-field-default branch 2 times, most recently from 3b86514 to 188d264 Compare May 25, 2023 15:05
@jplatte jplatte marked this pull request as ready for review May 25, 2023 15:05
@jplatte jplatte requested a review from a team as a code owner May 25, 2023 15:05
@jplatte jplatte requested review from mhammond and bendk and removed request for a team May 25, 2023 15:06
Copy link
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

Looks great to me. Unless @mhammond has concerns I think it's ready to merge.

Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

👍

},
FieldMetadata {
name: "age".into(),
ty: Type::U16,
default: None,
Copy link
Member

Choose a reason for hiding this comment

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

missed opportunity here for default: Default::default() :)

@@ -104,6 +104,12 @@ will fail).
pub struct MyRecord {
pub field_a: String,
pub field_b: Option<Arc<MyObject>>,
// Fields can have a default value.
// Currently, only string, integer, float and boolean literals are supported as defaults.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it is worth adding something like "these work the same way as documented for UDL files" or similar (the docs need a restructure, but udl/structs.md does describe this in some detail)

@jplatte jplatte force-pushed the jplatte/record-field-default branch from 188d264 to a9dfd35 Compare May 25, 2023 18:18
@jplatte jplatte merged commit 720d046 into mozilla:main May 25, 2023
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.

3 participants