-
Notifications
You must be signed in to change notification settings - Fork 672
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
Use enums for enumeration constants #254
Milestone
Comments
👍 |
homu
added a commit
that referenced
this issue
Feb 28, 2016
Add introduction/constants/enumeration/uninitialized to CONVENTIONS. I have added new sections to the file. I would like the usual suspects to read them critically and offer critique. When have agreed to add certain versions I will add Issues to track our progress in getting the code to follow the conventions. For two of the sections they already exist in #254 and #264.
Added a task list. |
Synonyms will not be allowed as variants. This results in enum Foo {
Bar = 0,
Baz = 0,
Quux = 1,
} |
We may be able to do something like this: pub enum Foo {
BAR = 0,
QUUX = 1,
}
use Foo::*;
pub const BAZ: Foo = BAR;
fn main() {
println!("{}", match BAR {
// We can even *match* using the synonym!
BAZ => "Is it a BAR? Could be a BAZ too!",
_ => "Not Ba{r,z} =(",
});
} |
Closed
wginolas
added a commit
to wginolas/nix
that referenced
this issue
Nov 5, 2017
Some enums which use different names for values than libc still set the discriminators manually. closes nix-rust#254
wginolas
added a commit
to wginolas/nix
that referenced
this issue
Nov 5, 2017
Some enums which use different names for values than libc still set the discriminators manually. closes nix-rust#254
wginolas
added a commit
to wginolas/nix
that referenced
this issue
Nov 5, 2017
Some enums which use different names for values than libc still set the discriminators manually. closes nix-rust#254
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just like we use bitflags! for flags, we could use enums for enumeration constants. They would provide a zero cost, type safe abstraction over the current primitive type constants.
A (partial) list of places to use enums:
sys::mman::MADV_*
sys::quota::Q_*
sys::signal::SIG*
The text was updated successfully, but these errors were encountered: