-
Notifications
You must be signed in to change notification settings - Fork 30
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 index getter to Variant
#110
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "scale-info" | ||
version = "0.9.1" | ||
version = "0.9.2" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2018" | ||
|
||
|
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
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? 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 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 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 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 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.
👍