Skip to content

Commit ae25ab6

Browse files
committed
Change std imports to core where possible
Useful for seeing what are the gaps toward being compatible with no-std. Useful for copying chunks of code into a no-std crate.
1 parent fa923c4 commit ae25ab6

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

src/ext.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use super::ToTokens;
2-
3-
use std::iter;
4-
2+
use core::iter;
53
use proc_macro2::{TokenStream, TokenTree};
64

75
/// TokenStream extension trait with methods for appending tokens.

src/ident_fragment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use core::fmt;
12
use proc_macro2::{Ident, Span};
23
use std::borrow::Cow;
3-
use std::fmt;
44

55
/// Specialized formatting trait used by `format_ident!`.
66
///

src/runtime.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::{IdentFragment, ToTokens, TokenStreamExt};
2-
use std::fmt;
3-
use std::iter;
4-
use std::ops::BitOr;
2+
use core::fmt;
3+
use core::iter;
4+
use core::ops::BitOr;
55

6+
pub use core::option::Option;
67
pub use proc_macro2::*;
78
pub use std::format;
8-
pub use std::option::Option;
99

1010
pub struct HasIterator; // True
1111
pub struct ThereIsNoIteratorInRepetition; // False
@@ -48,8 +48,8 @@ pub mod ext {
4848
use super::RepInterp;
4949
use super::{HasIterator as HasIter, ThereIsNoIteratorInRepetition as DoesNotHaveIter};
5050
use crate::ToTokens;
51+
use core::slice;
5152
use std::collections::btree_set::{self, BTreeSet};
52-
use std::slice;
5353

5454
/// Extension trait providing the `quote_into_iter` method on iterators.
5555
pub trait RepIteratorExt: Iterator + Sized {

src/to_tokens.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use super::TokenStreamExt;
2-
2+
use core::iter;
3+
use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
34
use std::borrow::Cow;
4-
use std::iter;
55
use std::rc::Rc;
66

7-
use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
8-
97
/// Types that can be interpolated inside a `quote!` invocation.
108
///
119
/// [`quote!`]: macro.quote.html

0 commit comments

Comments
 (0)