-
Notifications
You must be signed in to change notification settings - Fork 28
Add index getter to Variant
#110
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,6 +230,11 @@ where | |
| &self.fields | ||
| } | ||
|
|
||
| /// Returns the index of the variant, if specified. | ||
| pub fn index(&self) -> Option<u8> { | ||
| self.index | ||
| } | ||
|
Comment on lines
+233
to
+236
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference here from the discriminant?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The discriminant is only valid for "C Like" enums. If both are specified then the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay I see. Although we should keep in mind that there is a Rust RFC to allow for discriminants for data variants. Although then
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that would still hold true. You are correct that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If/when that lands and is stabilised we could deprecate the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discriminant removed in #112 |
||
|
|
||
| /// Returns the discriminant of the variant. | ||
| pub fn discriminant(&self) -> Option<u64> { | ||
| self.discriminant | ||
|
|
||
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.
👍