Comments (2)
Thanks for quick reaction!
w.r.t. why it was this way: I'm looking at handle_named_variant
and that looks very similar except in that case we have fields which means <
comparison catches it: perhaps unit was modeled on it and never adapted to do something more efficient. Maybe a range match is better there or something but that's for another day – unit variant is what I care about in this ticket.
from enum-map.
handle_named_variant
uses <
because it needs to (the number of variants is variable for named variants), and I assume handle_unit_variant
got <
from it.
As for why if
is used rather than match
, this is because match
arms don't accept const
expressions (inline-const is currently nightly only - rust-lang/rust#76001). At some point I think I would like to implement a special case for enums that only have unit variants that uses match
for those (to shorten compilation times when having a lot of enums), but I didn't do that yet
from enum-map.
Related Issues (14)
- Don't explicitly require importing enum_map_derive. HOT 1
- Stabilize enum-map HOT 2
- Derive Copy for EnumMap HOT 2
- Missing Ord and PartialOrd impls HOT 2
- enum_map! is unusable as a const initializer, and the array field being private makes manual initialization impossible too HOT 1
- Add EnumMap impl for Option<T: Enum> HOT 1
- Add a method for converting to an array (not a slice) HOT 1
- Clippy fails for single variant enum with Derive HOT 1
- Add Enum for tuples HOT 1
- Expose the `array` field (or add `as_array(&self) -> &K::Array`) HOT 8
- Default values for missing fields during deserialization HOT 2
- Derive Eq, Ord, PartialEq and PartialOrd on EnumMap<K,V> when K and V impl those traits HOT 2
- `from_usize` gives a generic, misleading panic message on out-of-bounds HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enum-map.