Skip to content

Commit

Permalink
Change std imports to core where possible
Browse files Browse the repository at this point in the history
Useful for seeing what are the gaps toward being compatible with
no-std. Useful for copying chunks of code into a no-std crate.
  • Loading branch information
dtolnay committed Aug 1, 2022
1 parent fa923c4 commit ae25ab6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/ext.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::ToTokens;

use std::iter;

use core::iter;
use proc_macro2::{TokenStream, TokenTree};

/// TokenStream extension trait with methods for appending tokens.
Expand Down
2 changes: 1 addition & 1 deletion src/ident_fragment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt;
use proc_macro2::{Ident, Span};
use std::borrow::Cow;
use std::fmt;

/// Specialized formatting trait used by `format_ident!`.
///
Expand Down
10 changes: 5 additions & 5 deletions src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{IdentFragment, ToTokens, TokenStreamExt};
use std::fmt;
use std::iter;
use std::ops::BitOr;
use core::fmt;
use core::iter;
use core::ops::BitOr;

pub use core::option::Option;
pub use proc_macro2::*;
pub use std::format;
pub use std::option::Option;

pub struct HasIterator; // True
pub struct ThereIsNoIteratorInRepetition; // False
Expand Down Expand Up @@ -48,8 +48,8 @@ pub mod ext {
use super::RepInterp;
use super::{HasIterator as HasIter, ThereIsNoIteratorInRepetition as DoesNotHaveIter};
use crate::ToTokens;
use core::slice;
use std::collections::btree_set::{self, BTreeSet};
use std::slice;

/// Extension trait providing the `quote_into_iter` method on iterators.
pub trait RepIteratorExt: Iterator + Sized {
Expand Down
6 changes: 2 additions & 4 deletions src/to_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use super::TokenStreamExt;

use core::iter;
use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
use std::borrow::Cow;
use std::iter;
use std::rc::Rc;

use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};

/// Types that can be interpolated inside a `quote!` invocation.
///
/// [`quote!`]: macro.quote.html
Expand Down

0 comments on commit ae25ab6

Please sign in to comment.