-
Notifications
You must be signed in to change notification settings - Fork 702
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 option to generate safe and unsafe conversions for rustified enums #2908
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// bindgen-flags: --rustified-enum 'Plain.*' --rustified-enum 'TryFromRaw.*=try_from_raw' --rustified-enum='FromRawUnchecked.*=from_raw_unchecked' --rustified-enum='Both.*=try_from_raw,from_raw_unchecked' --rustified-enum 'NonExhaustive.*=non_exhaustive' | ||
|
||
enum Plain { | ||
Plain1, | ||
Plain2, | ||
Plain3 | ||
}; | ||
|
||
enum TryFromRaw { | ||
TFR1 = -1, | ||
TFR2 = 5, | ||
TFR3 | ||
}; | ||
|
||
enum FromRawUnchecked { | ||
FRU1 = 6, | ||
FRU2 = 10, | ||
FRU3 = 11, | ||
}; | ||
|
||
enum Both { | ||
Both1, | ||
Both2 = -1, | ||
Both3, | ||
}; | ||
|
||
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. It could be a good idea to add a few functions here, e.g. |
||
enum NonExhaustive { | ||
Ex1, | ||
Ex2, | ||
}; |
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.
So this disallows a regex without options but with a
=
character, right? I guess we don't need that, but just noting it.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.
Yes, that's correct. If you provide no equal sign, it uses the empty option set.