Skip to content

Commit 5bc90bd

Browse files
committed
Refactor: tidy up imports and features
1 parent 79f6f5c commit 5bc90bd

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ readme = "README.md"
1010
categories = ["algorithms", "no-std"]
1111

1212
[features]
13+
default = ["alloc"]
1314
alloc = []
14-
std = []
15-
default = ["std"]

src/lib.rs

+14-29
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,22 @@
6767
#![warn(missing_docs)]
6868
#![no_std]
6969

70-
use core::cmp::{self, Ordering};
71-
use core::iter;
70+
use core::{
71+
cmp::{self, Ordering},
72+
iter,
73+
};
7274

73-
#[cfg(all(feature = "alloc", not(feature = "std")))]
74-
#[cfg_attr(test, macro_use)]
75+
#[cfg(feature = "alloc")]
7576
extern crate alloc;
7677

77-
#[cfg(all(feature = "alloc", not(feature = "std")))]
78-
mod imports {
79-
pub use alloc::boxed::Box;
80-
pub use alloc::collections::btree_map::BTreeMap;
81-
pub use alloc::collections::btree_set::BTreeSet;
82-
pub use alloc::vec::Vec;
83-
}
84-
85-
#[cfg(feature = "std")]
86-
#[cfg_attr(test, macro_use)]
87-
extern crate std;
88-
89-
#[cfg(feature = "std")]
90-
mod imports {
91-
pub use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
92-
pub use std::hash::{BuildHasher, Hash};
93-
pub use std::prelude::v1::*;
94-
}
95-
96-
#[cfg(any(feature = "std", feature = "alloc"))]
97-
use crate::imports::*;
78+
#[cfg(feature = "alloc")]
79+
pub use alloc::{
80+
boxed::Box,
81+
collections::{BTreeMap, BTreeSet},
82+
vec::Vec,
83+
};
9884

99-
#[cfg(any(feature = "std", feature = "alloc"))]
100-
#[cfg(test)]
85+
#[cfg(all(test, feature = "alloc"))]
10186
mod test;
10287

10388
enum FoldStop<T, E> {
@@ -1000,7 +985,7 @@ impl<I: DoubleEndedFallibleIterator + ?Sized> DoubleEndedFallibleIterator for &m
1000985
}
1001986
}
1002987

1003-
#[cfg(any(feature = "std", feature = "alloc"))]
988+
#[cfg(feature = "alloc")]
1004989
impl<I: FallibleIterator + ?Sized> FallibleIterator for Box<I> {
1005990
type Item = I::Item;
1006991
type Error = I::Error;
@@ -1021,7 +1006,7 @@ impl<I: FallibleIterator + ?Sized> FallibleIterator for Box<I> {
10211006
}
10221007
}
10231008

1024-
#[cfg(any(feature = "std", feature = "alloc"))]
1009+
#[cfg(feature = "alloc")]
10251010
impl<I: DoubleEndedFallibleIterator + ?Sized> DoubleEndedFallibleIterator for Box<I> {
10261011
#[inline]
10271012
fn next_back(&mut self) -> Result<Option<I::Item>, I::Error> {

src/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use core::iter;
2-
use core::ops::Range;
1+
use alloc::vec;
2+
use core::{iter, ops::Range};
33

44
use super::{convert, FallibleIterator, Vec};
55

0 commit comments

Comments
 (0)