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

Allow Settings Explicit Discriminants for Enums with Fields #688

Merged

Conversation

InsertCreativityHere
Copy link
Member

This PR allows users to set explicit discriminants for their enumerators, even if they have fields.
It also fixes the range of these discriminants so they must fit within [0, int32::MAX].

check_bounds(enum_def, &Primitive::VarInt32, diagnostics);
// For enumerators in Slice2, values must fit within varint32 and be positive.
let varint32_max = Primitive::VarInt32.numeric_bounds().unwrap().1;
check_bounds(enum_def, (0, varint32_max), diagnostics);
Copy link
Member

Choose a reason for hiding this comment

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

I find this varint32_max odd. Why define this max since it's == int32_max?

Copy link
Member Author

Choose a reason for hiding this comment

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

We definitely could.
I just thought it seemed cleaner to get the max from the actual Slice type, instead of the mapped type.
Using i32::MAX is obviously simpler though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched to using i32::MAX.

Copy link
Contributor

@ReeceHumphreys ReeceHumphreys left a comment

Choose a reason for hiding this comment

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

Looks good.

@InsertCreativityHere InsertCreativityHere merged commit 1c91683 into icerpc:main Dec 15, 2023
4 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.

4 participants