Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider using associated constants for the bitflag-like types #661
Comments
carllerche
added
the
help wanted
label
Aug 18, 2017
This comment has been minimized.
This comment has been minimized.
|
I want to learn the associated constraints feature, so I'm going to give this a shot. |
This comment has been minimized.
This comment has been minimized.
|
Great! Go for it. When it is done we will need to evaluate whether it is really an improvement over the current way. |
AndyGauge
referenced this issue
Aug 21, 2017
Closed
Associated Constants for Ready and PollOpt constructors #698
This comment has been minimized.
This comment has been minimized.
|
So one problem with using Associated Constants is that it breaks previous builds of Rust. Currently, Travis tests version 1.13 which will fail with the implementation of the feature. I also wanted to capture @carllerche comment about now that rustc 1.20 has dropped, the feature can be implemented in 12 weeks (12/24ish). |
This comment has been minimized.
This comment has been minimized.
|
I'm wondering why do you use struct(usize) and a number of associated constants instead of a plain enum? |
This comment has been minimized.
This comment has been minimized.
|
Mio will move away from bitflag style APIs in 0.7. This issue is no longer relevant. |
dtolnay commentedAug 18, 2017
The various Ready constructors currently work like this:
With the associated constants feature of Rust 1.20, it could work like this:
The constructors never do any work so they shouldn't need to be functions.
One advantage of constants is that they can be used in the pattern of a match statement.