1
+ use super :: super :: { navigate:: Position , node, DeterministicRng } ;
2
+ use super :: Entry :: { Occupied , Vacant } ;
3
+ use super :: * ;
1
4
use 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 ;
6
5
use crate :: fmt:: Debug ;
7
6
use crate :: rc:: Rc ;
8
- use crate :: string:: String ;
9
- use crate :: string:: ToString ;
7
+ use crate :: string:: { String , ToString } ;
10
8
use crate :: vec:: Vec ;
11
9
use std:: convert:: TryFrom ;
12
10
use std:: iter:: FromIterator ;
@@ -16,19 +14,17 @@ use std::ops::RangeBounds;
16
14
use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
17
15
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
18
16
19
- use super :: super :: DeterministicRng ;
20
-
21
17
// 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.
23
19
const NODE_CAPACITY : usize = node:: CAPACITY ;
24
20
25
21
// 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.
27
23
// It's not the minimum size: removing an element from such a tree does not always reduce height.
28
24
const MIN_INSERTS_HEIGHT_1 : usize = NODE_CAPACITY + 1 ;
29
25
30
26
// 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.
32
28
// It's not the minimum size: removing an element from such a tree does not always reduce height.
33
29
const MIN_INSERTS_HEIGHT_2 : usize = 89 ;
34
30
@@ -1386,44 +1382,65 @@ fn test_clone_from() {
1386
1382
}
1387
1383
}
1388
1384
1389
- #[ test]
1390
1385
#[ allow( dead_code) ]
1391
1386
fn test_variance ( ) {
1392
- use std:: collections:: btree_map:: { IntoIter , Iter , Keys , Range , Values } ;
1393
-
1394
1387
fn map_key < ' new > ( v : BTreeMap < & ' static str , ( ) > ) -> BTreeMap < & ' new str , ( ) > {
1395
1388
v
1396
1389
}
1397
1390
fn map_val < ' new > ( v : BTreeMap < ( ) , & ' static str > ) -> BTreeMap < ( ) , & ' new str > {
1398
1391
v
1399
1392
}
1393
+
1400
1394
fn iter_key < ' a , ' new > ( v : Iter < ' a , & ' static str , ( ) > ) -> Iter < ' a , & ' new str , ( ) > {
1401
1395
v
1402
1396
}
1403
1397
fn iter_val < ' a , ' new > ( v : Iter < ' a , ( ) , & ' static str > ) -> Iter < ' a , ( ) , & ' new str > {
1404
1398
v
1405
1399
}
1400
+
1406
1401
fn into_iter_key < ' new > ( v : IntoIter < & ' static str , ( ) > ) -> IntoIter < & ' new str , ( ) > {
1407
1402
v
1408
1403
}
1409
1404
fn into_iter_val < ' new > ( v : IntoIter < ( ) , & ' static str > ) -> IntoIter < ( ) , & ' new str > {
1410
1405
v
1411
1406
}
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
+
1412
1422
fn range_key < ' a , ' new > ( v : Range < ' a , & ' static str , ( ) > ) -> Range < ' a , & ' new str , ( ) > {
1413
1423
v
1414
1424
}
1415
1425
fn range_val < ' a , ' new > ( v : Range < ' a , ( ) , & ' static str > ) -> Range < ' a , ( ) , & ' new str > {
1416
1426
v
1417
1427
}
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 , ( ) > {
1419
1430
v
1420
1431
}
1421
- fn vals < ' a , ' new > ( v : Values < ' a , ( ) , & ' static str > ) -> Values < ' a , ( ) , & ' new str > {
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 , ( ) > {
1437
+ v
1438
+ }
1439
+ fn values_val < ' a , ' new > ( v : Values < ' a , ( ) , & ' static str > ) -> Values < ' a , ( ) , & ' new str > {
1422
1440
v
1423
1441
}
1424
1442
}
1425
1443
1426
- #[ test]
1427
1444
#[ allow( dead_code) ]
1428
1445
fn test_sync ( ) {
1429
1446
fn map < T : Sync > ( v : & BTreeMap < T , T > ) -> impl Sync + ' _ {
0 commit comments