@@ -15,66 +15,66 @@ mod owning_ref {
15
15
16
16
#[ test]
17
17
fn new_deref ( ) {
18
- let or: OwningRef < Box < ( ) > , ( ) > = OwningRef :: new ( box ( ( ) ) ) ;
18
+ let or: OwningRef < Box < ( ) > , ( ) > = OwningRef :: new ( Box :: new ( ( ) ) ) ;
19
19
assert_eq ! ( & * or, & ( ) ) ;
20
20
}
21
21
22
22
#[ test]
23
23
fn into ( ) {
24
- let or: OwningRef < Box < ( ) > , ( ) > = box ( ( ) ) . into ( ) ;
24
+ let or: OwningRef < Box < ( ) > , ( ) > = Box :: new ( ( ) ) . into ( ) ;
25
25
assert_eq ! ( & * or, & ( ) ) ;
26
26
}
27
27
28
28
#[ test]
29
29
fn map_offset_ref ( ) {
30
- let or: BoxRef < Example > = box ( example ( ) ) . into ( ) ;
30
+ let or: BoxRef < Example > = Box :: new ( example ( ) ) . into ( ) ;
31
31
let or: BoxRef < _ , u32 > = or. map ( |x| & x. 0 ) ;
32
32
assert_eq ! ( & * or, & 42 ) ;
33
33
34
- let or: BoxRef < Example > = box ( example ( ) ) . into ( ) ;
34
+ let or: BoxRef < Example > = Box :: new ( example ( ) ) . into ( ) ;
35
35
let or: BoxRef < _ , u8 > = or. map ( |x| & x. 2 [ 1 ] ) ;
36
36
assert_eq ! ( & * or, & 2 ) ;
37
37
}
38
38
39
39
#[ test]
40
40
fn map_heap_ref ( ) {
41
- let or: BoxRef < Example > = box ( example ( ) ) . into ( ) ;
41
+ let or: BoxRef < Example > = Box :: new ( example ( ) ) . into ( ) ;
42
42
let or: BoxRef < _ , str > = or. map ( |x| & x. 1 [ ..5 ] ) ;
43
43
assert_eq ! ( & * or, "hello" ) ;
44
44
}
45
45
46
46
#[ test]
47
47
fn map_static_ref ( ) {
48
- let or: BoxRef < ( ) > = box ( ( ) ) . into ( ) ;
48
+ let or: BoxRef < ( ) > = Box :: new ( ( ) ) . into ( ) ;
49
49
let or: BoxRef < _ , str > = or. map ( |_| "hello" ) ;
50
50
assert_eq ! ( & * or, "hello" ) ;
51
51
}
52
52
53
53
#[ test]
54
54
fn map_chained ( ) {
55
- let or: BoxRef < String > = box ( example ( ) . 1 ) . into ( ) ;
55
+ let or: BoxRef < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
56
56
let or: BoxRef < _ , str > = or. map ( |x| & x[ 1 ..5 ] ) ;
57
57
let or: BoxRef < _ , str > = or. map ( |x| & x[ ..2 ] ) ;
58
58
assert_eq ! ( & * or, "el" ) ;
59
59
}
60
60
61
61
#[ test]
62
62
fn map_chained_inference ( ) {
63
- let or = BoxRef :: new ( box ( example ( ) . 1 ) ) . map ( |x| & x[ ..5 ] ) . map ( |x| & x[ 1 ..3 ] ) ;
63
+ let or = BoxRef :: new ( Box :: new ( example ( ) . 1 ) ) . map ( |x| & x[ ..5 ] ) . map ( |x| & x[ 1 ..3 ] ) ;
64
64
assert_eq ! ( & * or, "el" ) ;
65
65
}
66
66
67
67
#[ test]
68
68
fn owner ( ) {
69
- let or: BoxRef < String > = box ( example ( ) . 1 ) . into ( ) ;
69
+ let or: BoxRef < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
70
70
let or = or. map ( |x| & x[ ..5 ] ) ;
71
71
assert_eq ! ( & * or, "hello" ) ;
72
72
assert_eq ! ( & * * or. owner( ) , "hello world" ) ;
73
73
}
74
74
75
75
#[ test]
76
76
fn into_inner ( ) {
77
- let or: BoxRef < String > = box ( example ( ) . 1 ) . into ( ) ;
77
+ let or: BoxRef < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
78
78
let or = or. map ( |x| & x[ ..5 ] ) ;
79
79
assert_eq ! ( & * or, "hello" ) ;
80
80
let s = * or. into_inner ( ) ;
@@ -83,17 +83,17 @@ mod owning_ref {
83
83
84
84
#[ test]
85
85
fn fmt_debug ( ) {
86
- let or: BoxRef < String > = box ( example ( ) . 1 ) . into ( ) ;
86
+ let or: BoxRef < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
87
87
let or = or. map ( |x| & x[ ..5 ] ) ;
88
88
let s = format ! ( "{:?}" , or) ;
89
89
assert_eq ! ( & s, "OwningRef { owner: \" hello world\" , reference: \" hello\" }" ) ;
90
90
}
91
91
92
92
#[ test]
93
93
fn erased_owner ( ) {
94
- let o1: BoxRef < Example , str > = BoxRef :: new ( box ( example ( ) ) ) . map ( |x| & x. 1 [ ..] ) ;
94
+ let o1: BoxRef < Example , str > = BoxRef :: new ( Box :: new ( example ( ) ) ) . map ( |x| & x. 1 [ ..] ) ;
95
95
96
- let o2: BoxRef < String , str > = BoxRef :: new ( box ( example ( ) . 1 ) ) . map ( |x| & x[ ..] ) ;
96
+ let o2: BoxRef < String , str > = BoxRef :: new ( Box :: new ( example ( ) . 1 ) ) . map ( |x| & x[ ..] ) ;
97
97
98
98
let os: Vec < ErasedBoxRef < str > > = vec ! [ o1. erase_owner( ) , o2. erase_owner( ) ] ;
99
99
assert ! ( os. iter( ) . all( |e| & e[ ..] == "hello world" ) ) ;
@@ -238,7 +238,7 @@ mod owning_ref {
238
238
fn try_map1 ( ) {
239
239
use std:: any:: Any ;
240
240
241
- let x = box ( 123_i32 ) ;
241
+ let x = Box :: new ( 123_i32 ) ;
242
242
let y: Box < dyn Any > = x;
243
243
244
244
assert ! ( OwningRef :: new( y) . try_map( |x| x. downcast_ref:: <i32 >( ) . ok_or( ( ) ) ) . is_ok( ) ) ;
@@ -248,7 +248,7 @@ mod owning_ref {
248
248
fn try_map2 ( ) {
249
249
use std:: any:: Any ;
250
250
251
- let x = box ( 123_i32 ) ;
251
+ let x = Box :: new ( 123_i32 ) ;
252
252
let y: Box < dyn Any > = x;
253
253
254
254
assert ! ( !OwningRef :: new( y) . try_map( |x| x. downcast_ref:: <i32 >( ) . ok_or( ( ) ) ) . is_err( ) ) ;
@@ -377,69 +377,69 @@ mod owning_ref_mut {
377
377
378
378
#[ test]
379
379
fn new_deref ( ) {
380
- let or: OwningRefMut < Box < ( ) > , ( ) > = OwningRefMut :: new ( box ( ( ) ) ) ;
380
+ let or: OwningRefMut < Box < ( ) > , ( ) > = OwningRefMut :: new ( Box :: new ( ( ) ) ) ;
381
381
assert_eq ! ( & * or, & ( ) ) ;
382
382
}
383
383
384
384
#[ test]
385
385
fn new_deref_mut ( ) {
386
- let mut or: OwningRefMut < Box < ( ) > , ( ) > = OwningRefMut :: new ( box ( ( ) ) ) ;
386
+ let mut or: OwningRefMut < Box < ( ) > , ( ) > = OwningRefMut :: new ( Box :: new ( ( ) ) ) ;
387
387
assert_eq ! ( & mut * or, & mut ( ) ) ;
388
388
}
389
389
390
390
#[ test]
391
391
fn mutate ( ) {
392
- let mut or: OwningRefMut < Box < usize > , usize > = OwningRefMut :: new ( box ( 0 ) ) ;
392
+ let mut or: OwningRefMut < Box < usize > , usize > = OwningRefMut :: new ( Box :: new ( 0 ) ) ;
393
393
assert_eq ! ( & * or, & 0 ) ;
394
394
* or = 1 ;
395
395
assert_eq ! ( & * or, & 1 ) ;
396
396
}
397
397
398
398
#[ test]
399
399
fn into ( ) {
400
- let or: OwningRefMut < Box < ( ) > , ( ) > = box ( ( ) ) . into ( ) ;
400
+ let or: OwningRefMut < Box < ( ) > , ( ) > = Box :: new ( ( ) ) . into ( ) ;
401
401
assert_eq ! ( & * or, & ( ) ) ;
402
402
}
403
403
404
404
#[ test]
405
405
fn map_offset_ref ( ) {
406
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
406
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
407
407
let or: BoxRef < _ , u32 > = or. map ( |x| & mut x. 0 ) ;
408
408
assert_eq ! ( & * or, & 42 ) ;
409
409
410
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
410
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
411
411
let or: BoxRef < _ , u8 > = or. map ( |x| & mut x. 2 [ 1 ] ) ;
412
412
assert_eq ! ( & * or, & 2 ) ;
413
413
}
414
414
415
415
#[ test]
416
416
fn map_heap_ref ( ) {
417
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
417
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
418
418
let or: BoxRef < _ , str > = or. map ( |x| & mut x. 1 [ ..5 ] ) ;
419
419
assert_eq ! ( & * or, "hello" ) ;
420
420
}
421
421
422
422
#[ test]
423
423
fn map_static_ref ( ) {
424
- let or: BoxRefMut < ( ) > = box ( ( ) ) . into ( ) ;
424
+ let or: BoxRefMut < ( ) > = Box :: new ( ( ) ) . into ( ) ;
425
425
let or: BoxRef < _ , str > = or. map ( |_| "hello" ) ;
426
426
assert_eq ! ( & * or, "hello" ) ;
427
427
}
428
428
429
429
#[ test]
430
430
fn map_mut_offset_ref ( ) {
431
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
431
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
432
432
let or: BoxRefMut < _ , u32 > = or. map_mut ( |x| & mut x. 0 ) ;
433
433
assert_eq ! ( & * or, & 42 ) ;
434
434
435
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
435
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
436
436
let or: BoxRefMut < _ , u8 > = or. map_mut ( |x| & mut x. 2 [ 1 ] ) ;
437
437
assert_eq ! ( & * or, & 2 ) ;
438
438
}
439
439
440
440
#[ test]
441
441
fn map_mut_heap_ref ( ) {
442
- let or: BoxRefMut < Example > = box ( example ( ) ) . into ( ) ;
442
+ let or: BoxRefMut < Example > = Box :: new ( example ( ) ) . into ( ) ;
443
443
let or: BoxRefMut < _ , str > = or. map_mut ( |x| & mut x. 1 [ ..5 ] ) ;
444
444
assert_eq ! ( & * or, "hello" ) ;
445
445
}
@@ -450,14 +450,14 @@ mod owning_ref_mut {
450
450
451
451
let mut_s: & ' static mut [ u8 ] = unsafe { & mut MUT_S } ;
452
452
453
- let or: BoxRefMut < ( ) > = box ( ( ) ) . into ( ) ;
453
+ let or: BoxRefMut < ( ) > = Box :: new ( ( ) ) . into ( ) ;
454
454
let or: BoxRefMut < _ , [ u8 ] > = or. map_mut ( move |_| mut_s) ;
455
455
assert_eq ! ( & * or, b"hello" ) ;
456
456
}
457
457
458
458
#[ test]
459
459
fn map_mut_chained ( ) {
460
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
460
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
461
461
let or: BoxRefMut < _ , str > = or. map_mut ( |x| & mut x[ 1 ..5 ] ) ;
462
462
let or: BoxRefMut < _ , str > = or. map_mut ( |x| & mut x[ ..2 ] ) ;
463
463
assert_eq ! ( & * or, "el" ) ;
@@ -466,32 +466,32 @@ mod owning_ref_mut {
466
466
#[ test]
467
467
fn map_chained_inference ( ) {
468
468
let or =
469
- BoxRefMut :: new ( box ( example ( ) . 1 ) ) . map_mut ( |x| & mut x[ ..5 ] ) . map_mut ( |x| & mut x[ 1 ..3 ] ) ;
469
+ BoxRefMut :: new ( Box :: new ( example ( ) . 1 ) ) . map_mut ( |x| & mut x[ ..5 ] ) . map_mut ( |x| & mut x[ 1 ..3 ] ) ;
470
470
assert_eq ! ( & * or, "el" ) ;
471
471
}
472
472
473
473
#[ test]
474
474
fn try_map_mut ( ) {
475
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
475
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
476
476
let or: Result < BoxRefMut < _ , str > , ( ) > = or. try_map_mut ( |x| Ok ( & mut x[ 1 ..5 ] ) ) ;
477
477
assert_eq ! ( & * or. unwrap( ) , "ello" ) ;
478
478
479
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
479
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
480
480
let or: Result < BoxRefMut < _ , str > , ( ) > = or. try_map_mut ( |_| Err ( ( ) ) ) ;
481
481
assert ! ( or. is_err( ) ) ;
482
482
}
483
483
484
484
#[ test]
485
485
fn owner ( ) {
486
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
486
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
487
487
let or = or. map_mut ( |x| & mut x[ ..5 ] ) ;
488
488
assert_eq ! ( & * or, "hello" ) ;
489
489
assert_eq ! ( & * * or. owner( ) , "hello world" ) ;
490
490
}
491
491
492
492
#[ test]
493
493
fn into_inner ( ) {
494
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
494
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
495
495
let or = or. map_mut ( |x| & mut x[ ..5 ] ) ;
496
496
assert_eq ! ( & * or, "hello" ) ;
497
497
let s = * or. into_inner ( ) ;
@@ -500,17 +500,17 @@ mod owning_ref_mut {
500
500
501
501
#[ test]
502
502
fn fmt_debug ( ) {
503
- let or: BoxRefMut < String > = box ( example ( ) . 1 ) . into ( ) ;
503
+ let or: BoxRefMut < String > = Box :: new ( example ( ) . 1 ) . into ( ) ;
504
504
let or = or. map_mut ( |x| & mut x[ ..5 ] ) ;
505
505
let s = format ! ( "{:?}" , or) ;
506
506
assert_eq ! ( & s, "OwningRefMut { owner: \" hello world\" , reference: \" hello\" }" ) ;
507
507
}
508
508
509
509
#[ test]
510
510
fn erased_owner ( ) {
511
- let o1: BoxRefMut < Example , str > = BoxRefMut :: new ( box ( example ( ) ) ) . map_mut ( |x| & mut x. 1 [ ..] ) ;
511
+ let o1: BoxRefMut < Example , str > = BoxRefMut :: new ( Box :: new ( example ( ) ) ) . map_mut ( |x| & mut x. 1 [ ..] ) ;
512
512
513
- let o2: BoxRefMut < String , str > = BoxRefMut :: new ( box ( example ( ) . 1 ) ) . map_mut ( |x| & mut x[ ..] ) ;
513
+ let o2: BoxRefMut < String , str > = BoxRefMut :: new ( Box :: new ( example ( ) . 1 ) ) . map_mut ( |x| & mut x[ ..] ) ;
514
514
515
515
let os: Vec < ErasedBoxRefMut < str > > = vec ! [ o1. erase_owner( ) , o2. erase_owner( ) ] ;
516
516
assert ! ( os. iter( ) . all( |e| & e[ ..] == "hello world" ) ) ;
@@ -593,8 +593,8 @@ mod owning_ref_mut {
593
593
#[ test]
594
594
fn borrow ( ) {
595
595
let mut hash = HashMap :: new ( ) ;
596
- let key1 = BoxRefMut :: < String > :: new ( box ( "foo" . to_string ( ) ) ) . map ( |s| & s[ ..] ) ;
597
- let key2 = BoxRefMut :: < String > :: new ( box ( "bar" . to_string ( ) ) ) . map ( |s| & s[ ..] ) ;
596
+ let key1 = BoxRefMut :: < String > :: new ( Box :: new ( "foo" . to_string ( ) ) ) . map ( |s| & s[ ..] ) ;
597
+ let key2 = BoxRefMut :: < String > :: new ( Box :: new ( "bar" . to_string ( ) ) ) . map ( |s| & s[ ..] ) ;
598
598
599
599
hash. insert ( key1, 42 ) ;
600
600
hash. insert ( key2, 23 ) ;
@@ -633,7 +633,7 @@ mod owning_ref_mut {
633
633
fn try_map1 ( ) {
634
634
use std:: any:: Any ;
635
635
636
- let x = box ( 123_i32 ) ;
636
+ let x = Box :: new ( 123_i32 ) ;
637
637
let y: Box < dyn Any > = x;
638
638
639
639
assert ! ( OwningRefMut :: new( y) . try_map_mut( |x| x. downcast_mut:: <i32 >( ) . ok_or( ( ) ) ) . is_ok( ) ) ;
@@ -643,7 +643,7 @@ mod owning_ref_mut {
643
643
fn try_map2 ( ) {
644
644
use std:: any:: Any ;
645
645
646
- let x = box ( 123_i32 ) ;
646
+ let x = Box :: new ( 123_i32 ) ;
647
647
let y: Box < dyn Any > = x;
648
648
649
649
assert ! ( !OwningRefMut :: new( y) . try_map_mut( |x| x. downcast_mut:: <i32 >( ) . ok_or( ( ) ) ) . is_err( ) ) ;
@@ -653,7 +653,7 @@ mod owning_ref_mut {
653
653
fn try_map3 ( ) {
654
654
use std:: any:: Any ;
655
655
656
- let x = box ( 123_i32 ) ;
656
+ let x = Box :: new ( 123_i32 ) ;
657
657
let y: Box < dyn Any > = x;
658
658
659
659
assert ! ( OwningRefMut :: new( y) . try_map( |x| x. downcast_ref:: <i32 >( ) . ok_or( ( ) ) ) . is_ok( ) ) ;
@@ -663,7 +663,7 @@ mod owning_ref_mut {
663
663
fn try_map4 ( ) {
664
664
use std:: any:: Any ;
665
665
666
- let x = box ( 123_i32 ) ;
666
+ let x = Box :: new ( 123_i32 ) ;
667
667
let y: Box < dyn Any > = x;
668
668
669
669
assert ! ( !OwningRefMut :: new( y) . try_map( |x| x. downcast_ref:: <i32 >( ) . ok_or( ( ) ) ) . is_err( ) ) ;
@@ -673,7 +673,7 @@ mod owning_ref_mut {
673
673
fn into_owning_ref ( ) {
674
674
use super :: super :: BoxRef ;
675
675
676
- let or: BoxRefMut < ( ) > = box ( ( ) ) . into ( ) ;
676
+ let or: BoxRefMut < ( ) > = Box :: new ( ( ) ) . into ( ) ;
677
677
let or: BoxRef < ( ) > = or. into ( ) ;
678
678
assert_eq ! ( & * or, & ( ) ) ;
679
679
}
0 commit comments