@@ -468,3 +468,65 @@ impl<T, A> RawWeak<T, A> {
468468 }
469469 }
470470}
471+
472+ impl < T , A > RawWeak < [ T ] , A > {
473+ #[ cfg( not( no_global_oom_handling) ) ]
474+ fn allocate < F > ( length : usize , allocate_fn : F ) -> Self
475+ where
476+ A : Allocator ,
477+ F : FnOnce ( RcLayout ) -> ( RcValuePointer , A ) ,
478+ {
479+ let rc_layout = RcLayout :: new_array :: < T > ( length) ;
480+ let ( ptr, alloc) = allocate_fn ( rc_layout) ;
481+
482+ unsafe {
483+ Self :: from_raw_parts ( NonNull :: slice_from_raw_parts ( ptr. as_ptr ( ) . cast ( ) , length) , alloc)
484+ }
485+ }
486+
487+ #[ cfg( not( no_global_oom_handling) ) ]
488+ fn allocate_in < F > ( length : usize , alloc : A , allocate_fn : F ) -> Self
489+ where
490+ A : Allocator ,
491+ F : FnOnce ( & A , RcLayout ) -> RcValuePointer ,
492+ {
493+ let rc_layout = RcLayout :: new_array :: < T > ( length) ;
494+ let ptr = allocate_fn ( & alloc, rc_layout) ;
495+
496+ unsafe {
497+ Self :: from_raw_parts ( NonNull :: slice_from_raw_parts ( ptr. as_ptr ( ) . cast ( ) , length) , alloc)
498+ }
499+ }
500+
501+ #[ cfg( not( no_global_oom_handling) ) ]
502+ pub ( crate ) fn new_uninit_slice < const STRONG_COUNT : usize > ( length : usize ) -> Self
503+ where
504+ A : Allocator + Default ,
505+ {
506+ Self :: allocate ( length, super :: allocate_uninit :: < A , STRONG_COUNT > )
507+ }
508+
509+ #[ cfg( not( no_global_oom_handling) ) ]
510+ pub ( crate ) fn new_uninit_slice_in < const STRONG_COUNT : usize > ( length : usize , alloc : A ) -> Self
511+ where
512+ A : Allocator ,
513+ {
514+ Self :: allocate_in ( length, alloc, super :: allocate_uninit_in :: < A , STRONG_COUNT > )
515+ }
516+
517+ #[ cfg( not( no_global_oom_handling) ) ]
518+ pub ( crate ) fn new_zeroed_slice < const STRONG_COUNT : usize > ( length : usize ) -> Self
519+ where
520+ A : Allocator + Default ,
521+ {
522+ Self :: allocate ( length, super :: allocate_zeroed :: < A , STRONG_COUNT > )
523+ }
524+
525+ #[ cfg( not( no_global_oom_handling) ) ]
526+ pub ( crate ) fn new_zeroed_slice_in < const STRONG_COUNT : usize > ( length : usize , alloc : A ) -> Self
527+ where
528+ A : Allocator ,
529+ {
530+ Self :: allocate_in ( length, alloc, super :: allocate_zeroed_in :: < A , STRONG_COUNT > )
531+ }
532+ }
0 commit comments