1+ use super :: super :: { navigate:: Position , node, DeterministicRng } ;
2+ use super :: Entry :: { Occupied , Vacant } ;
3+ use super :: * ;
14use crate :: boxed:: Box ;
2- use crate :: collections:: btree:: navigate:: Position ;
3- use crate :: collections:: btree:: node;
4- use crate :: collections:: btree_map:: Entry :: { Occupied , Vacant } ;
5- use crate :: collections:: BTreeMap ;
65use crate :: fmt:: Debug ;
76use crate :: rc:: Rc ;
8- use crate :: string:: String ;
9- use crate :: string:: ToString ;
7+ use crate :: string:: { String , ToString } ;
108use crate :: vec:: Vec ;
119use std:: convert:: TryFrom ;
1210use std:: iter:: FromIterator ;
@@ -16,19 +14,17 @@ use std::ops::RangeBounds;
1614use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
1715use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
1816
19- use super :: super :: DeterministicRng ;
20-
2117// Capacity of a tree with a single level,
22- // i.e. a tree who's root is a leaf node at height 0.
18+ // i.e., a tree who's root is a leaf node at height 0.
2319const NODE_CAPACITY : usize = node:: CAPACITY ;
2420
2521// Minimum number of elements to insert, to guarantee a tree with 2 levels,
26- // i.e. a tree who's root is an internal node at height 1, with edges to leaf nodes.
22+ // i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes.
2723// It's not the minimum size: removing an element from such a tree does not always reduce height.
2824const MIN_INSERTS_HEIGHT_1 : usize = NODE_CAPACITY + 1 ;
2925
3026// Minimum number of elements to insert in ascending order, to guarantee a tree with 3 levels,
31- // i.e. a tree who's root is an internal node at height 2, with edges to more internal nodes.
27+ // i.e., a tree who's root is an internal node at height 2, with edges to more internal nodes.
3228// It's not the minimum size: removing an element from such a tree does not always reduce height.
3329const MIN_INSERTS_HEIGHT_2 : usize = 89 ;
3430
@@ -1386,44 +1382,65 @@ fn test_clone_from() {
13861382 }
13871383}
13881384
1389- #[ test]
13901385#[ allow( dead_code) ]
13911386fn test_variance ( ) {
1392- use std:: collections:: btree_map:: { IntoIter , Iter , Keys , Range , Values } ;
1393-
13941387 fn map_key < ' new > ( v : BTreeMap < & ' static str , ( ) > ) -> BTreeMap < & ' new str , ( ) > {
13951388 v
13961389 }
13971390 fn map_val < ' new > ( v : BTreeMap < ( ) , & ' static str > ) -> BTreeMap < ( ) , & ' new str > {
13981391 v
13991392 }
1393+
14001394 fn iter_key < ' a , ' new > ( v : Iter < ' a , & ' static str , ( ) > ) -> Iter < ' a , & ' new str , ( ) > {
14011395 v
14021396 }
14031397 fn iter_val < ' a , ' new > ( v : Iter < ' a , ( ) , & ' static str > ) -> Iter < ' a , ( ) , & ' new str > {
14041398 v
14051399 }
1400+
14061401 fn into_iter_key < ' new > ( v : IntoIter < & ' static str , ( ) > ) -> IntoIter < & ' new str , ( ) > {
14071402 v
14081403 }
14091404 fn into_iter_val < ' new > ( v : IntoIter < ( ) , & ' static str > ) -> IntoIter < ( ) , & ' new str > {
14101405 v
14111406 }
1407+
1408+ fn into_keys_key < ' new > ( v : IntoKeys < & ' static str , ( ) > ) -> IntoKeys < & ' new str , ( ) > {
1409+ v
1410+ }
1411+ fn into_keys_val < ' new > ( v : IntoKeys < ( ) , & ' static str > ) -> IntoKeys < ( ) , & ' new str > {
1412+ v
1413+ }
1414+
1415+ fn into_values_key < ' new > ( v : IntoValues < & ' static str , ( ) > ) -> IntoValues < & ' new str , ( ) > {
1416+ v
1417+ }
1418+ fn into_values_val < ' new > ( v : IntoValues < ( ) , & ' static str > ) -> IntoValues < ( ) , & ' new str > {
1419+ v
1420+ }
1421+
14121422 fn range_key < ' a , ' new > ( v : Range < ' a , & ' static str , ( ) > ) -> Range < ' a , & ' new str , ( ) > {
14131423 v
14141424 }
14151425 fn range_val < ' a , ' new > ( v : Range < ' a , ( ) , & ' static str > ) -> Range < ' a , ( ) , & ' new str > {
14161426 v
14171427 }
1418- fn keys < ' a , ' new > ( v : Keys < ' a , & ' static str , ( ) > ) -> Keys < ' a , & ' new str , ( ) > {
1428+
1429+ fn keys_key < ' a , ' new > ( v : Keys < ' a , & ' static str , ( ) > ) -> Keys < ' a , & ' new str , ( ) > {
1430+ v
1431+ }
1432+ fn keys_val < ' a , ' new > ( v : Keys < ' a , ( ) , & ' static str > ) -> Keys < ' a , ( ) , & ' new str > {
1433+ v
1434+ }
1435+
1436+ fn values_key < ' a , ' new > ( v : Values < ' a , & ' static str , ( ) > ) -> Values < ' a , & ' new str , ( ) > {
14191437 v
14201438 }
1421- fn vals < ' a , ' new > ( v : Values < ' a , ( ) , & ' static str > ) -> Values < ' a , ( ) , & ' new str > {
1439+ fn values_val < ' a , ' new > ( v : Values < ' a , ( ) , & ' static str > ) -> Values < ' a , ( ) , & ' new str > {
14221440 v
14231441 }
14241442}
14251443
1426- #[ test]
14271444#[ allow( dead_code) ]
14281445fn test_sync ( ) {
14291446 fn map < T : Sync > ( v : & BTreeMap < T , T > ) -> impl Sync + ' _ {
@@ -1493,7 +1510,6 @@ fn test_sync() {
14931510 }
14941511}
14951512
1496- #[ test]
14971513#[ allow( dead_code) ]
14981514fn test_send ( ) {
14991515 fn map < T : Send > ( v : BTreeMap < T , T > ) -> impl Send {
@@ -1520,7 +1536,7 @@ fn test_send() {
15201536 v. iter ( )
15211537 }
15221538
1523- fn iter_mut < T : Send + Sync > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
1539+ fn iter_mut < T : Send > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
15241540 v. iter_mut ( )
15251541 }
15261542
@@ -1532,15 +1548,15 @@ fn test_send() {
15321548 v. values ( )
15331549 }
15341550
1535- fn values_mut < T : Send + Sync > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
1551+ fn values_mut < T : Send > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
15361552 v. values_mut ( )
15371553 }
15381554
15391555 fn range < T : Send + Sync + Ord > ( v : & BTreeMap < T , T > ) -> impl Send + ' _ {
15401556 v. range ( ..)
15411557 }
15421558
1543- fn range_mut < T : Send + Sync + Ord > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
1559+ fn range_mut < T : Send + Ord > ( v : & mut BTreeMap < T , T > ) -> impl Send + ' _ {
15441560 v. range_mut ( ..)
15451561 }
15461562
0 commit comments