2828//! To use this feature add `features = ["union"]` in the `smallvec` section of Cargo.toml.
2929//! Note that this feature requires a nightly compiler (for now).
3030
31- #![ cfg_attr( not( feature = "std" ) , no_std) ]
32- #![ cfg_attr( not( feature = "std" ) , feature( alloc) ) ]
33- #![ cfg_attr( feature = "union" , feature( untagged_unions) ) ]
34- #![ cfg_attr( feature = "specialization" , feature( specialization) ) ]
3531#![ cfg_attr( feature = "may_dangle" , feature( dropck_eyepatch) ) ]
32+ #![ cfg_attr( feature = "specialization" , feature( specialization) ) ]
33+ #![ cfg_attr( feature = "union" , feature( untagged_unions) ) ]
34+ #![ cfg_attr( not( feature = "alloc" ) , no_std) ]
3635#![ deny( missing_docs) ]
3736
38-
39- #[ cfg( not( feature = "std" ) ) ]
40- #[ macro_use]
37+ #[ cfg( feature = "alloc" ) ]
4138extern crate alloc;
4239
43- #[ cfg( not( feature = "std" ) ) ]
44- use alloc:: vec:: Vec ;
45-
4640#[ cfg( feature = "serde" ) ]
4741extern crate serde;
4842
49- #[ cfg( not( feature = "std" ) ) ]
50- mod std {
51- pub use core:: * ;
52- }
53-
54- use std:: borrow:: { Borrow , BorrowMut } ;
55- use std:: cmp;
56- use std:: fmt;
57- use std:: hash:: { Hash , Hasher } ;
58- use std:: iter:: { IntoIterator , FromIterator , repeat} ;
59- use std:: mem;
60- use std:: mem:: ManuallyDrop ;
61- use std:: ops;
62- use std:: ptr;
63- use std:: slice;
43+ use core:: {
44+ borrow:: { Borrow , BorrowMut } ,
45+ cmp,
46+ fmt,
47+ hash:: { Hash , Hasher } ,
48+ iter:: { IntoIterator , FromIterator , repeat} ,
49+ mem:: { ManuallyDrop , self } ,
50+ ops,
51+ ptr,
52+ slice,
53+ } ;
6454#[ cfg( feature = "std" ) ]
6555use std:: io;
6656#[ cfg( feature = "serde" ) ]
67- use serde:: ser:: { Serialize , Serializer , SerializeSeq } ;
68- #[ cfg( feature = "serde" ) ]
69- use serde:: de:: { Deserialize , Deserializer , SeqAccess , Visitor } ;
70- #[ cfg( feature = "serde" ) ]
71- use std:: marker:: PhantomData ;
57+ use {
58+ serde:: {
59+ ser:: { Serialize , Serializer , SerializeSeq } ,
60+ de:: { Deserialize , Deserializer , SeqAccess , Visitor } ,
61+ } ,
62+ core:: marker:: PhantomData
63+ } ;
7264
7365/// Creates a [`SmallVec`] containing the arguments.
7466///
@@ -821,7 +813,7 @@ impl<A: Array> SmallVec<A> {
821813 }
822814
823815 let ( lower_size_bound, _) = iter. size_hint ( ) ;
824- assert ! ( lower_size_bound <= std :: isize :: MAX as usize ) ; // Ensure offset is indexable
816+ assert ! ( lower_size_bound <= core :: isize :: MAX as usize ) ; // Ensure offset is indexable
825817 assert ! ( index + lower_size_bound >= index) ; // Protect against overflow
826818 self . reserve ( lower_size_bound) ;
827819
@@ -1121,7 +1113,7 @@ impl<A: Array> SmallVec<A> where A::Item: Clone {
11211113 let mut local_len = SetLenOnDrop :: new ( len_ptr) ;
11221114
11231115 for i in 0 ..n as isize {
1124- :: std :: ptr:: write ( ptr. offset ( i) , elem. clone ( ) ) ;
1116+ core :: ptr:: write ( ptr. offset ( i) , elem. clone ( ) ) ;
11251117 local_len. increment_len ( 1 ) ;
11261118 }
11271119 }
@@ -1606,9 +1598,9 @@ impl_array!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32
16061598
16071599#[ cfg( test) ]
16081600mod tests {
1609- use SmallVec ;
1601+ use crate :: SmallVec ;
16101602
1611- use std :: iter:: FromIterator ;
1603+ use core :: iter:: FromIterator ;
16121604
16131605 #[ cfg( feature = "std" ) ]
16141606 use std:: borrow:: ToOwned ;
@@ -1766,7 +1758,7 @@ mod tests {
17661758
17671759 #[ test]
17681760 fn into_iter_drop ( ) {
1769- use std :: cell:: Cell ;
1761+ use core :: cell:: Cell ;
17701762
17711763 struct DropCounter < ' a > ( & ' a Cell < i32 > ) ;
17721764
@@ -2061,7 +2053,7 @@ mod tests {
20612053
20622054 #[ test]
20632055 fn test_borrow ( ) {
2064- use std :: borrow:: Borrow ;
2056+ use core :: borrow:: Borrow ;
20652057
20662058 let mut a: SmallVec < [ u32 ; 2 ] > = SmallVec :: new ( ) ;
20672059 a. push ( 1 ) ;
@@ -2074,7 +2066,7 @@ mod tests {
20742066
20752067 #[ test]
20762068 fn test_borrow_mut ( ) {
2077- use std :: borrow:: BorrowMut ;
2069+ use core :: borrow:: BorrowMut ;
20782070
20792071 let mut a: SmallVec < [ u32 ; 2 ] > = SmallVec :: new ( ) ;
20802072 a. push ( 1 ) ;
@@ -2279,7 +2271,7 @@ mod tests {
22792271 #[ cfg( feature = "std" ) ]
22802272 #[ test]
22812273 fn test_write ( ) {
2282- use io:: Write ;
2274+ use std :: io:: Write ;
22832275
22842276 let data = [ 1 , 2 , 3 , 4 , 5 ] ;
22852277
0 commit comments