File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed
Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -8,10 +8,6 @@ alternative to the built-in `#[derive(FromPrimitive)]`, which
88requires the unstable ` std::num::FromPrimitive ` and is disabled in
99Rust 1.0.
1010
11- The current implementation requires all variants of the enum to
12- have an explicit discriminator value. This restriction may be
13- relaxed in future versions.
14-
1511## Documentation
1612
1713https://andersk.github.io/enum_primitive-rs/enum_primitive/
@@ -40,12 +36,14 @@ enum_from_primitive! {
4036enum FooBar {
4137 Foo = 17 ,
4238 Bar = 42 ,
39+ Baz ,
4340}
4441}
4542
4643fn main () {
4744 assert_eq! (FooBar :: from_i32 (17 ), Some (FooBar :: Foo ));
4845 assert_eq! (FooBar :: from_i32 (42 ), Some (FooBar :: Bar ));
46+ assert_eq! (FooBar :: from_i32 (43 ), Some (FooBar :: Baz ));
4947 assert_eq! (FooBar :: from_i32 (91 ), None );
5048}
5149```
Original file line number Diff line number Diff line change 2828//! requires the unstable `std::num::FromPrimitive` and is disabled in
2929//! Rust 1.0.
3030//!
31- //! The current implementation requires all variants of the enum to
32- //! have an explicit discriminator value. This restriction may be
33- //! relaxed in future versions.
34- //!
3531//! # Example
3632//!
3733//! ```
You can’t perform that action at this time.
0 commit comments