3131#![ cfg_attr( feature = "may_dangle" , feature( dropck_eyepatch) ) ]
3232#![ cfg_attr( feature = "specialization" , feature( specialization) ) ]
3333#![ cfg_attr( feature = "union" , feature( untagged_unions) ) ]
34- #![ cfg_attr( not( feature = "alloc" ) , no_std) ]
3534#![ deny( missing_docs) ]
3635
37- #[ cfg( feature = "alloc" ) ]
38- extern crate alloc;
39-
40- #[ cfg( feature = "serde" ) ]
41- extern crate serde;
42-
4336use core:: {
4437 borrow:: { Borrow , BorrowMut } ,
4538 cmp,
@@ -1543,23 +1536,15 @@ impl_array!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32
15431536
15441537#[ cfg( test) ]
15451538mod tests {
1546- use crate :: SmallVec ;
1539+ extern crate alloc ;
15471540
1541+ use crate :: SmallVec ;
1542+ use alloc:: {
1543+ rc:: Rc ,
1544+ boxed:: Box ,
1545+ } ;
15481546 use core:: iter:: FromIterator ;
15491547
1550- #[ cfg( feature = "std" ) ]
1551- use std:: borrow:: ToOwned ;
1552- #[ cfg( not( feature = "std" ) ) ]
1553- use alloc:: borrow:: ToOwned ;
1554- #[ cfg( feature = "std" ) ]
1555- use std:: rc:: Rc ;
1556- #[ cfg( not( feature = "std" ) ) ]
1557- use alloc:: rc:: Rc ;
1558- #[ cfg( not( feature = "std" ) ) ]
1559- use alloc:: boxed:: Box ;
1560- #[ cfg( not( feature = "std" ) ) ]
1561- use alloc:: vec:: Vec ;
1562-
15631548 #[ test]
15641549 pub fn test_zero ( ) {
15651550 let mut v = SmallVec :: < [ _ ; 0 ] > :: new ( ) ;
@@ -1574,51 +1559,51 @@ mod tests {
15741559 #[ test]
15751560 pub fn test_inline ( ) {
15761561 let mut v = SmallVec :: < [ _ ; 16 ] > :: new ( ) ;
1577- v. push ( "hello" . to_owned ( ) ) ;
1578- v. push ( "there" . to_owned ( ) ) ;
1562+ v. push ( "hello" ) ;
1563+ v. push ( "there" ) ;
15791564 assert_eq ! ( & * v, & [
1580- "hello" . to_owned ( ) ,
1581- "there" . to_owned ( ) ,
1565+ "hello" ,
1566+ "there" ,
15821567 ] [ ..] ) ;
15831568 }
15841569
15851570 #[ test]
15861571 pub fn test_spill ( ) {
15871572 let mut v = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
1588- v. push ( "hello" . to_owned ( ) ) ;
1573+ v. push ( "hello" ) ;
15891574 assert_eq ! ( v[ 0 ] , "hello" ) ;
1590- v. push ( "there" . to_owned ( ) ) ;
1591- v. push ( "burma" . to_owned ( ) ) ;
1575+ v. push ( "there" ) ;
1576+ v. push ( "burma" ) ;
15921577 assert_eq ! ( v[ 0 ] , "hello" ) ;
1593- v. push ( "shave" . to_owned ( ) ) ;
1578+ v. push ( "shave" ) ;
15941579 assert_eq ! ( & * v, & [
1595- "hello" . to_owned ( ) ,
1596- "there" . to_owned ( ) ,
1597- "burma" . to_owned ( ) ,
1598- "shave" . to_owned ( ) ,
1580+ "hello" ,
1581+ "there" ,
1582+ "burma" ,
1583+ "shave" ,
15991584 ] [ ..] ) ;
16001585 }
16011586
16021587 #[ test]
16031588 pub fn test_double_spill ( ) {
16041589 let mut v = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
1605- v. push ( "hello" . to_owned ( ) ) ;
1606- v. push ( "there" . to_owned ( ) ) ;
1607- v. push ( "burma" . to_owned ( ) ) ;
1608- v. push ( "shave" . to_owned ( ) ) ;
1609- v. push ( "hello" . to_owned ( ) ) ;
1610- v. push ( "there" . to_owned ( ) ) ;
1611- v. push ( "burma" . to_owned ( ) ) ;
1612- v. push ( "shave" . to_owned ( ) ) ;
1590+ v. push ( "hello" ) ;
1591+ v. push ( "there" ) ;
1592+ v. push ( "burma" ) ;
1593+ v. push ( "shave" ) ;
1594+ v. push ( "hello" ) ;
1595+ v. push ( "there" ) ;
1596+ v. push ( "burma" ) ;
1597+ v. push ( "shave" ) ;
16131598 assert_eq ! ( & * v, & [
1614- "hello" . to_owned ( ) ,
1615- "there" . to_owned ( ) ,
1616- "burma" . to_owned ( ) ,
1617- "shave" . to_owned ( ) ,
1618- "hello" . to_owned ( ) ,
1619- "there" . to_owned ( ) ,
1620- "burma" . to_owned ( ) ,
1621- "shave" . to_owned ( ) ,
1599+ "hello" ,
1600+ "there" ,
1601+ "burma" ,
1602+ "shave" ,
1603+ "hello" ,
1604+ "there" ,
1605+ "burma" ,
1606+ "shave" ,
16221607 ] [ ..] ) ;
16231608 }
16241609
0 commit comments