@@ -2378,14 +2378,14 @@ fn test_cursor_mut() {
2378
2378
assert_eq ! ( cur. peek_next( ) , Some ( ( & 5 , & mut 'e' ) ) ) ;
2379
2379
assert_eq ! ( cur. peek_prev( ) , Some ( ( & 3 , & mut 'c' ) ) ) ;
2380
2380
2381
- cur. insert_before ( 4 , 'd' ) ;
2381
+ cur. insert_before ( 4 , 'd' ) . unwrap ( ) ;
2382
2382
assert_eq ! ( cur. peek_next( ) , Some ( ( & 5 , & mut 'e' ) ) ) ;
2383
2383
assert_eq ! ( cur. peek_prev( ) , Some ( ( & 4 , & mut 'd' ) ) ) ;
2384
2384
2385
2385
assert_eq ! ( cur. next( ) , Some ( ( & 5 , & mut 'e' ) ) ) ;
2386
2386
assert_eq ! ( cur. peek_next( ) , None ) ;
2387
2387
assert_eq ! ( cur. peek_prev( ) , Some ( ( & 5 , & mut 'e' ) ) ) ;
2388
- cur. insert_before ( 6 , 'f' ) ;
2388
+ cur. insert_before ( 6 , 'f' ) . unwrap ( ) ;
2389
2389
assert_eq ! ( cur. peek_next( ) , None ) ;
2390
2390
assert_eq ! ( cur. peek_prev( ) , Some ( ( & 6 , & mut 'f' ) ) ) ;
2391
2391
assert_eq ! ( cur. remove_prev( ) , Some ( ( 6 , 'f' ) ) ) ;
@@ -2409,14 +2409,14 @@ fn test_cursor_mut_key() {
2409
2409
assert_eq ! ( cur. peek_next( ) , Some ( ( & mut 5 , & mut 'e' ) ) ) ;
2410
2410
assert_eq ! ( cur. peek_prev( ) , Some ( ( & mut 3 , & mut 'c' ) ) ) ;
2411
2411
2412
- cur. insert_before ( 4 , 'd' ) ;
2412
+ cur. insert_before ( 4 , 'd' ) . unwrap ( ) ;
2413
2413
assert_eq ! ( cur. peek_next( ) , Some ( ( & mut 5 , & mut 'e' ) ) ) ;
2414
2414
assert_eq ! ( cur. peek_prev( ) , Some ( ( & mut 4 , & mut 'd' ) ) ) ;
2415
2415
2416
2416
assert_eq ! ( cur. next( ) , Some ( ( & mut 5 , & mut 'e' ) ) ) ;
2417
2417
assert_eq ! ( cur. peek_next( ) , None ) ;
2418
2418
assert_eq ! ( cur. peek_prev( ) , Some ( ( & mut 5 , & mut 'e' ) ) ) ;
2419
- cur. insert_before ( 6 , 'f' ) ;
2419
+ cur. insert_before ( 6 , 'f' ) . unwrap ( ) ;
2420
2420
assert_eq ! ( cur. peek_next( ) , None ) ;
2421
2421
assert_eq ! ( cur. peek_prev( ) , Some ( ( & mut 6 , & mut 'f' ) ) ) ;
2422
2422
assert_eq ! ( cur. remove_prev( ) , Some ( ( 6 , 'f' ) ) ) ;
@@ -2439,74 +2439,66 @@ fn test_cursor_empty() {
2439
2439
let mut cur = map. lower_bound_mut ( Bound :: Excluded ( & 3 ) ) ;
2440
2440
assert_eq ! ( cur. peek_next( ) , None ) ;
2441
2441
assert_eq ! ( cur. peek_prev( ) , None ) ;
2442
- cur. insert_after ( 0 , 0 ) ;
2442
+ cur. insert_after ( 0 , 0 ) . unwrap ( ) ;
2443
2443
assert_eq ! ( cur. peek_next( ) , Some ( ( & 0 , & mut 0 ) ) ) ;
2444
2444
assert_eq ! ( cur. peek_prev( ) , None ) ;
2445
2445
assert_eq ! ( map, BTreeMap :: from( [ ( 0 , 0 ) ] ) ) ;
2446
2446
}
2447
2447
2448
- #[ should_panic( expected = "key must be ordered above the previous element" ) ]
2449
2448
#[ test]
2450
2449
fn test_cursor_mut_insert_before_1 ( ) {
2451
2450
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2452
2451
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2453
- cur. insert_before ( 0 , 'd' ) ;
2452
+ cur. insert_before ( 0 , 'd' ) . unwrap_err ( ) ;
2454
2453
}
2455
2454
2456
- #[ should_panic( expected = "key must be ordered above the previous element" ) ]
2457
2455
#[ test]
2458
2456
fn test_cursor_mut_insert_before_2 ( ) {
2459
2457
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2460
2458
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2461
- cur. insert_before ( 1 , 'd' ) ;
2459
+ cur. insert_before ( 1 , 'd' ) . unwrap_err ( ) ;
2462
2460
}
2463
2461
2464
- #[ should_panic( expected = "key must be ordered above the previous element" ) ]
2465
2462
#[ test]
2466
2463
fn test_cursor_mut_insert_before_3 ( ) {
2467
2464
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2468
2465
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2469
- cur. insert_before ( 2 , 'd' ) ;
2466
+ cur. insert_before ( 2 , 'd' ) . unwrap_err ( ) ;
2470
2467
}
2471
2468
2472
- #[ should_panic( expected = "key must be ordered below the next element" ) ]
2473
2469
#[ test]
2474
2470
fn test_cursor_mut_insert_before_4 ( ) {
2475
2471
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2476
2472
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2477
- cur. insert_before ( 3 , 'd' ) ;
2473
+ cur. insert_before ( 3 , 'd' ) . unwrap_err ( ) ;
2478
2474
}
2479
2475
2480
- #[ should_panic( expected = "key must be ordered above the previous element" ) ]
2481
2476
#[ test]
2482
2477
fn test_cursor_mut_insert_after_1 ( ) {
2483
2478
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2484
2479
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2485
- cur. insert_after ( 1 , 'd' ) ;
2480
+ cur. insert_after ( 1 , 'd' ) . unwrap_err ( ) ;
2486
2481
}
2487
2482
2488
- #[ should_panic( expected = "key must be ordered above the previous element" ) ]
2489
2483
#[ test]
2490
2484
fn test_cursor_mut_insert_after_2 ( ) {
2491
2485
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2492
2486
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2493
- cur. insert_after ( 2 , 'd' ) ;
2487
+ cur. insert_after ( 2 , 'd' ) . unwrap_err ( ) ;
2494
2488
}
2495
2489
2496
- #[ should_panic( expected = "key must be ordered below the next element" ) ]
2497
2490
#[ test]
2498
2491
fn test_cursor_mut_insert_after_3 ( ) {
2499
2492
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2500
2493
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2501
- cur. insert_after ( 3 , 'd' ) ;
2494
+ cur. insert_after ( 3 , 'd' ) . unwrap_err ( ) ;
2502
2495
}
2503
2496
2504
- #[ should_panic( expected = "key must be ordered below the next element" ) ]
2505
2497
#[ test]
2506
2498
fn test_cursor_mut_insert_after_4 ( ) {
2507
2499
let mut map = BTreeMap :: from ( [ ( 1 , 'a' ) , ( 2 , 'b' ) , ( 3 , 'c' ) ] ) ;
2508
2500
let mut cur = map. upper_bound_mut ( Bound :: Included ( & 2 ) ) ;
2509
- cur. insert_after ( 4 , 'd' ) ;
2501
+ cur. insert_after ( 4 , 'd' ) . unwrap_err ( ) ;
2510
2502
}
2511
2503
2512
2504
#[ test]
0 commit comments