If you use set the discriminant of a C-like enum with a macro the derive panics. This happens with both ToPrimitive and FromPrimitive.
Minimal example:
#[macro_use]
extern crate num_derive;
extern crate num_traits;
macro_rules! get_an_isize {
() => (0_isize)
}
#[derive(FromPrimitive)]
pub enum CLikeEnum {
VarA = get_an_isize!(), // panics
VarB = 2,
}
Errors with
error: proc-macro derive panicked
--> src\lib.rs:9:10
|
9 | #[derive(FromPrimitive)]
| ^^^^^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: ParseError(Some("failed to parse derive input: failed to parse"))
Cargo.toml:
[dependencies]
num-traits = "0.2"
num-derive = "0.2"
Rust version:
rustc 1.27.0 (3eda71b00 2018-06-19)
If you use set the discriminant of a C-like enum with a macro the derive panics. This happens with both
ToPrimitiveandFromPrimitive.Minimal example:
Errors with
Cargo.toml:
Rust version:
rustc 1.27.0 (3eda71b00 2018-06-19)