4 ms·
I like the IDEA but the implementation is not the good one. Instead, this is what will be elegant: pub enum SearchOption { Left, Full,
by mamcx 7y ago
I like the IDEA but the implementation is not the good one.
Instead, this is what will be elegant:
pub enum SearchOption {
Left,
Full,
}
pub enum SearchOptionBeta:SearchOption {
Rigth,
}
Yep, extending struct and enums.
This mean MATCH touch "SearchOption" as the "stable" API and the inner crate touch SearchOptionBeta. When SearchOptionBeta need magic is that it match SearchOption too. Later is just a matter of replace one for the other.
And this is even useful for more than to stabilize certain fields or arms...
- swsieber 7y agoI'd personally do this: pub enum SearchOption { Left, Full, Beta(SearchOptionBeta), } #[non_exhaustive] pub enum SearchOptionBeta { Right }
- mamcx 7y agoYeah, this is how could be done with this, but also show why is a poor abstraction. If enums were abled to be extended: match e: SearchOptionBeta { SearchOptionBeta:: Left, Rigth, Full }