Skip to content

Commit 4c8f2f2

Browse files
authored
Fix nightly build / simplify no_std (#30)
We were using `alloc` as `std` when the `std` feature was not present. However, there is a new nightly warning about redundant imports that this was raising, as `use std::vec::Vec`, for example, is not needed when using `std`. Instead, we just use `alloc` always.
1 parent bd8c572 commit 4c8f2f2

File tree

6 files changed

+12
-26
lines changed

6 files changed

+12
-26
lines changed

src/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use alloc::{format, vec::Vec};
12
use proc_macro2::TokenStream as TokenStream2;
23
use quote::{format_ident, quote};
3-
use std::{format, vec::Vec};
44
use syn::{punctuated::Punctuated, DeriveInput, Generics, Ident, Token, TypeParamBound, Variant};
55

66
use crate::{

src/enum.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use std::collections::{BTreeMap, BTreeSet};
2-
use std::vec::Vec;
3-
1+
use alloc::{
2+
collections::{BTreeMap, BTreeSet},
3+
vec::Vec,
4+
};
45
use proc_macro2::TokenStream;
56
use syn::{punctuated::Punctuated, Generics, Ident, Token, TypeParamBound, Variant};
67

src/extractor.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::borrow::ToOwned;
2-
use std::boxed::Box;
3-
use std::vec::Vec;
1+
use alloc::{borrow::ToOwned, boxed::Box, vec::Vec};
42
use syn::{Ident, Lifetime, Type, TypeParamBound};
53

64
use crate::{iter::BoxedIter, param::Param};

src/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::boxed::Box;
1+
use alloc::boxed::Box;
22

33
pub trait BoxedIter {
44
type Item;

src/lib.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#![doc = include_str!("../README.md")]
2-
#![cfg_attr(not(feature = "std"), no_std)]
2+
#![no_std]
33

4-
#[cfg(feature = "std")]
5-
extern crate std;
6-
7-
#[cfg(not(feature = "std"))]
8-
extern crate alloc as std;
4+
extern crate alloc;
95

106
mod build;
117
mod derive;
@@ -14,9 +10,7 @@ mod extractor;
1410
mod iter;
1511
mod param;
1612

17-
use std::collections::BTreeMap;
18-
#[cfg(not(feature = "std"))]
19-
use std::{borrow::ToOwned, string::ToString, vec::Vec};
13+
use alloc::{borrow::ToOwned, collections::BTreeMap, string::ToString, vec::Vec};
2014

2115
use derive::Derive;
2216
use heck::ToSnakeCase;
@@ -170,12 +164,7 @@ pub fn subenum(args: TokenStream, tokens: TokenStream) -> TokenStream {
170164
};
171165

172166
// We want all attributes except the "subenum" one.
173-
var.attrs = var
174-
.attrs
175-
.iter()
176-
.cloned()
177-
.filter(|attr| attribute != attr)
178-
.collect();
167+
var.attrs.retain(|attr| attribute != attr);
179168

180169
let e = enums
181170
.get_mut(ident)

src/param.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::collections::BTreeMap;
2-
use std::vec::Vec;
3-
1+
use alloc::{collections::BTreeMap, vec::Vec};
42
use syn::{GenericParam, Generics, Ident, Lifetime, TypeParamBound, WherePredicate};
53

64
use crate::extractor::Extractor;

0 commit comments

Comments
 (0)