Skip to content

Fix code duplication error #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down