Merge pull request #242 from rust-num/feat/do-not-duplicate-enum-definition

Fix code duplication error

(Overriding a CI failure due to `num-macros`.)
This commit is contained in:
Josh Stone 2016-11-28 09:39:36 -08:00 committed by GitHub
commit d7cbdb509c
1 changed files with 1 additions and 6 deletions

View File

@ -30,10 +30,7 @@ pub fn from_primitive(input: TokenStream) -> TokenStream {
let variants = match ast.body {
Enum(ref variants) => variants,
_ => {
panic!("`FromPrimitive` can be applied only to the enums, {} is not an enum",
name)
}
_ => panic!("`FromPrimitive` can be applied only to the enums, {} is not an enum", name)
};
let mut idx = 0;
@ -56,8 +53,6 @@ pub fn from_primitive(input: TokenStream) -> TokenStream {
.collect();
let res = quote! {
#ast
impl ::num::traits::FromPrimitive for #name {
fn from_i64(n: i64) -> Option<Self> {
Self::from_u64(n as u64)