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
8
8
requires the unstable ` std::num::FromPrimitive ` and is disabled in
9
9
Rust 1.0.
10
10
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
-
15
11
## Documentation
16
12
17
13
https://andersk.github.io/enum_primitive-rs/enum_primitive/
@@ -40,12 +36,14 @@ enum_from_primitive! {
40
36
enum FooBar {
41
37
Foo = 17 ,
42
38
Bar = 42 ,
39
+ Baz ,
43
40
}
44
41
}
45
42
46
43
fn main () {
47
44
assert_eq! (FooBar :: from_i32 (17 ), Some (FooBar :: Foo ));
48
45
assert_eq! (FooBar :: from_i32 (42 ), Some (FooBar :: Bar ));
46
+ assert_eq! (FooBar :: from_i32 (43 ), Some (FooBar :: Baz ));
49
47
assert_eq! (FooBar :: from_i32 (91 ), None );
50
48
}
51
49
```
Original file line number Diff line number Diff line change 28
28
//! requires the unstable `std::num::FromPrimitive` and is disabled in
29
29
//! Rust 1.0.
30
30
//!
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
- //!
35
31
//! # Example
36
32
//!
37
33
//! ```
You can’t perform that action at this time.
0 commit comments