31
31
#![ cfg_attr( feature = "may_dangle" , feature( dropck_eyepatch) ) ]
32
32
#![ cfg_attr( feature = "specialization" , feature( specialization) ) ]
33
33
#![ cfg_attr( feature = "union" , feature( untagged_unions) ) ]
34
- #![ cfg_attr( not( feature = "alloc" ) , no_std) ]
35
34
#![ deny( missing_docs) ]
36
35
37
- #[ cfg( feature = "alloc" ) ]
38
- extern crate alloc;
39
-
40
- #[ cfg( feature = "serde" ) ]
41
- extern crate serde;
42
-
43
36
use core:: {
44
37
borrow:: { Borrow , BorrowMut } ,
45
38
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
1543
1536
1544
1537
#[ cfg( test) ]
1545
1538
mod tests {
1546
- use crate :: SmallVec ;
1539
+ extern crate alloc ;
1547
1540
1541
+ use crate :: SmallVec ;
1542
+ use alloc:: {
1543
+ rc:: Rc ,
1544
+ boxed:: Box ,
1545
+ } ;
1548
1546
use core:: iter:: FromIterator ;
1549
1547
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
-
1563
1548
#[ test]
1564
1549
pub fn test_zero ( ) {
1565
1550
let mut v = SmallVec :: < [ _ ; 0 ] > :: new ( ) ;
@@ -1574,51 +1559,51 @@ mod tests {
1574
1559
#[ test]
1575
1560
pub fn test_inline ( ) {
1576
1561
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" ) ;
1579
1564
assert_eq ! ( & * v, & [
1580
- "hello" . to_owned ( ) ,
1581
- "there" . to_owned ( ) ,
1565
+ "hello" ,
1566
+ "there" ,
1582
1567
] [ ..] ) ;
1583
1568
}
1584
1569
1585
1570
#[ test]
1586
1571
pub fn test_spill ( ) {
1587
1572
let mut v = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
1588
- v. push ( "hello" . to_owned ( ) ) ;
1573
+ v. push ( "hello" ) ;
1589
1574
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" ) ;
1592
1577
assert_eq ! ( v[ 0 ] , "hello" ) ;
1593
- v. push ( "shave" . to_owned ( ) ) ;
1578
+ v. push ( "shave" ) ;
1594
1579
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" ,
1599
1584
] [ ..] ) ;
1600
1585
}
1601
1586
1602
1587
#[ test]
1603
1588
pub fn test_double_spill ( ) {
1604
1589
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" ) ;
1613
1598
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" ,
1622
1607
] [ ..] ) ;
1623
1608
}
1624
1609
0 commit comments