Skip to content

Commit eeccb29

Browse files
Change relative to absolute paths and make compatible with #![no_std]
1 parent c1b8645 commit eeccb29

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "enum-utils"
3-
version = "0.1.2" # remember to update html_root_url
3+
version = "0.1.3" # remember to update html_root_url
44
authors = ["Dylan MacKenzie <[email protected]>"]
55
edition = "2018"
66

from-str/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ impl ToTokens for StrMapFunc {
122122
_ => {}
123123
}
124124

125-
None
125+
::core::option::Option::None
126126
};
127127

128128
tokens.extend(quote! {
129-
fn #func_name(s: &[u8]) -> Option<#ret_ty> {
129+
fn #func_name(s: &[u8]) -> ::core::option::Option<#ret_ty> {
130130
#body
131131
}
132132
});
@@ -201,7 +201,7 @@ impl<T> Forest<T>
201201
if let Some(v) = node.value {
202202
// TODO: debug_assert_eq!(dfs.next().0, Post);
203203

204-
tok.last_mut().unwrap().extend(quote!(return Some(#v);));
204+
tok.last_mut().unwrap().extend(quote!(return ::core::option::Option::Some(#v);));
205205
}
206206
}
207207

src/conv.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ pub fn derive_try_from_repr(input: &syn::DeriveInput) -> Result<TokenStream, Err
4848
.map(|(v, ctor)| quote!(const #v: #repr = #ctor as #repr));
4949

5050
Ok(quote! {
51-
impl ::std::convert::TryFrom<#repr> for #name {
51+
impl ::core::convert::TryFrom<#repr> for #name {
5252
type Error = ();
5353

5454
#[allow(non_upper_case_globals)]
55-
fn try_from(d: #repr) -> Result<Self, Self::Error> {
55+
fn try_from(d: #repr) -> ::core::result::Result<Self, Self::Error> {
5656

5757
#( #const_defs; )*
5858

5959
match d {
60-
#( #consts => Ok(#ctors), )*
61-
_ => Err(())
60+
#( #consts => ::core::result::Result::Ok(#ctors), )*
61+
_ => ::core::result::Result::Err(())
6262
}
6363
}
6464
}
@@ -91,7 +91,7 @@ pub fn derive_repr_from(input: &syn::DeriveInput) -> Result<TokenStream, ErrorLi
9191
}
9292

9393
Ok(quote! {
94-
impl ::std::convert::From<#name> for #repr {
94+
impl ::core::convert::From<#name> for #repr {
9595
fn from(d: #name) -> Self {
9696
d as #repr
9797
}

src/from_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ pub fn derive(ast: &syn::DeriveInput) -> Result<TokenStream, ErrorList> {
6868
}
6969

7070
Ok(quote!{
71-
impl ::std::str::FromStr for #enum_name {
71+
impl ::core::str::FromStr for #enum_name {
7272
type Err = ();
7373

74-
fn from_str(s: &str) -> Result<Self, Self::Err> {
74+
fn from_str(s: &str) -> ::core::result::Result<Self, Self::Err> {
7575
#trie
7676
_parse(s.as_bytes()).ok_or(())
7777
}

src/iter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl IterImpl {
9797
fn tokens(&self, ty: &syn::Ident) -> TokenStream {
9898
let body = match self {
9999
IterImpl::Empty => quote! {
100-
::std::iter::empty()
100+
::core::iter::empty()
101101
},
102102

103103
IterImpl::Range { range, repr } => {
@@ -107,7 +107,7 @@ impl IterImpl {
107107
quote! {
108108
let start: #repr = #start;
109109
let end: #repr = #end;
110-
(start .. end).map(|discrim| unsafe { ::std::mem::transmute(discrim) })
110+
(start .. end).map(|discrim| unsafe { ::core::mem::transmute(discrim) })
111111
}
112112
},
113113

@@ -117,7 +117,7 @@ impl IterImpl {
117117
quote! {
118118
let start: #repr = #start;
119119
let end: #repr = #end;
120-
(start ..= end).map(|discrim| unsafe { ::std::mem::transmute(discrim) })
120+
(start ..= end).map(|discrim| unsafe { ::core::mem::transmute(discrim) })
121121
}
122122
},
123123

@@ -130,7 +130,7 @@ impl IterImpl {
130130

131131
quote! {
132132
impl #ty {
133-
fn iter() -> impl Iterator<Item = #ty> + Clone {
133+
fn iter() -> impl ::core::iter::Iterator<Item = #ty> + ::core::clone::Clone {
134134
#body
135135
}
136136
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A set of procedural macros for deriving useful functionality on enums.
22
3-
#![doc(html_root_url = "https://docs.rs/enum-utils/0.1.2")]
3+
#![doc(html_root_url = "https://docs.rs/enum-utils/0.1.3")]
44

55
extern crate proc_macro;
66

0 commit comments

Comments
 (0)