Skip to content

Commit

Permalink
Merge branch 'no-std' into 'master'
Browse files Browse the repository at this point in the history
Use core for no_std support

See merge request cardoe/enum-primitive-derive!5
  • Loading branch information
cardoe committed Jun 19, 2020
2 parents 6dcbc17 + 047f82b commit d39f168
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ gitlab = { repository = "cardoe/enum-primitive-derive" }
proc-macro = true

[dependencies]
num-traits = "0.2"
quote = "1"
syn = "1"

[dependencies.num-traits]
version = "0.2"
default-features = false
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
//!
//! ```rust
//! use enum_primitive_derive::Primitive;
//! use std::convert::TryFrom;
//! use core::convert::TryFrom;
//!
//! #[derive(Debug, Eq, PartialEq, Primitive)]
//! enum Foo {
Expand Down Expand Up @@ -192,7 +192,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<u64> for #to_name {
impl ::core::convert::TryFrom<u64> for #to_name {
type Error = &'static str;

fn try_from(value: u64) -> Result<Self, Self::Error> {
Expand All @@ -202,7 +202,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<u32> for #to_name {
impl ::core::convert::TryFrom<u32> for #to_name {
type Error = &'static str;

fn try_from(value: u32) -> Result<Self, Self::Error> {
Expand All @@ -212,7 +212,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<u16> for #to_name {
impl ::core::convert::TryFrom<u16> for #to_name {
type Error = &'static str;

fn try_from(value: u16) -> Result<Self, Self::Error> {
Expand All @@ -222,7 +222,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<u8> for #to_name {
impl ::core::convert::TryFrom<u8> for #to_name {
type Error = &'static str;

fn try_from(value: u8) -> Result<Self, Self::Error> {
Expand All @@ -232,7 +232,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<i64> for #name {
impl ::core::convert::TryFrom<i64> for #name {
type Error = &'static str;

fn try_from(value: i64) -> Result<Self, Self::Error> {
Expand All @@ -242,7 +242,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<i32> for #name {
impl ::core::convert::TryFrom<i32> for #name {
type Error = &'static str;

fn try_from(value: i32) -> Result<Self, Self::Error> {
Expand All @@ -252,7 +252,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<i16> for #name {
impl ::core::convert::TryFrom<i16> for #name {
type Error = &'static str;

fn try_from(value: i16) -> Result<Self, Self::Error> {
Expand All @@ -262,7 +262,7 @@ fn impl_primitive(ast: &syn::DeriveInput) -> TokenStream {
}
}

impl ::std::convert::TryFrom<i8> for #name {
impl ::core::convert::TryFrom<i8> for #name {
type Error = &'static str;

fn try_from(value: i8) -> Result<Self, Self::Error> {
Expand Down

0 comments on commit d39f168

Please sign in to comment.