@@ -5,7 +5,7 @@ use core::clone::CloneToUninit;
5
5
use core:: marker:: PhantomData ;
6
6
#[ cfg( not( no_global_oom_handling) ) ]
7
7
use core:: mem;
8
- use core:: mem:: DropGuard ;
8
+ use core:: mem:: { DropGuard , MaybeUninit } ;
9
9
#[ cfg( not( no_global_oom_handling) ) ]
10
10
use core:: ops:: DerefMut ;
11
11
#[ cfg( not( no_global_oom_handling) ) ]
@@ -479,3 +479,69 @@ impl<T, A> RawRc<T, A> {
479
479
} )
480
480
}
481
481
}
482
+
483
+ impl < T , A > RawRc < MaybeUninit < T > , A > {
484
+ pub ( crate ) fn try_new_uninit ( ) -> Result < Self , AllocError >
485
+ where
486
+ A : Allocator + Default ,
487
+ {
488
+ RawWeak :: try_new_uninit :: < 1 > ( ) . map ( |weak| unsafe { Self :: from_weak ( weak) } )
489
+ }
490
+
491
+ pub ( crate ) fn try_new_uninit_in ( alloc : A ) -> Result < Self , AllocError >
492
+ where
493
+ A : Allocator ,
494
+ {
495
+ RawWeak :: try_new_uninit_in :: < 1 > ( alloc) . map ( |weak| unsafe { Self :: from_weak ( weak) } )
496
+ }
497
+
498
+ pub ( crate ) fn try_new_zeroed ( ) -> Result < Self , AllocError >
499
+ where
500
+ A : Allocator + Default ,
501
+ {
502
+ RawWeak :: try_new_zeroed :: < 1 > ( ) . map ( |weak| unsafe { Self :: from_weak ( weak) } )
503
+ }
504
+
505
+ pub ( crate ) fn try_new_zeroed_in ( alloc : A ) -> Result < Self , AllocError >
506
+ where
507
+ A : Allocator ,
508
+ {
509
+ RawWeak :: try_new_zeroed_in :: < 1 > ( alloc) . map ( |weak| unsafe { Self :: from_weak ( weak) } )
510
+ }
511
+
512
+ #[ cfg( not( no_global_oom_handling) ) ]
513
+ pub ( crate ) fn new_uninit ( ) -> Self
514
+ where
515
+ A : Allocator + Default ,
516
+ {
517
+ unsafe { Self :: from_weak ( RawWeak :: new_uninit :: < 1 > ( ) ) }
518
+ }
519
+
520
+ #[ cfg( not( no_global_oom_handling) ) ]
521
+ pub ( crate ) fn new_uninit_in ( alloc : A ) -> Self
522
+ where
523
+ A : Allocator ,
524
+ {
525
+ unsafe { Self :: from_weak ( RawWeak :: new_uninit_in :: < 1 > ( alloc) ) }
526
+ }
527
+
528
+ #[ cfg( not( no_global_oom_handling) ) ]
529
+ pub ( crate ) fn new_zeroed ( ) -> Self
530
+ where
531
+ A : Allocator + Default ,
532
+ {
533
+ unsafe { Self :: from_weak ( RawWeak :: new_zeroed :: < 1 > ( ) ) }
534
+ }
535
+
536
+ #[ cfg( not( no_global_oom_handling) ) ]
537
+ pub ( crate ) fn new_zeroed_in ( alloc : A ) -> Self
538
+ where
539
+ A : Allocator ,
540
+ {
541
+ unsafe { Self :: from_weak ( RawWeak :: new_zeroed_in :: < 1 > ( alloc) ) }
542
+ }
543
+
544
+ pub ( crate ) unsafe fn assume_init ( self ) -> RawRc < T , A > {
545
+ unsafe { self . cast ( ) }
546
+ }
547
+ }
0 commit comments