@@ -4780,3 +4780,55 @@ unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for UniqueArc<T, A> {
47804780 unsafe { ptr:: drop_in_place ( & mut ( * self . ptr . as_ptr ( ) ) . data ) } ;
47814781 }
47824782}
4783+
4784+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
4785+ unsafe impl < T : ?Sized + Allocator , A : Allocator > Allocator for Arc < T , A > {
4786+ #[ inline]
4787+ fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocError > {
4788+ ( * * self ) . allocate ( layout)
4789+ }
4790+
4791+ #[ inline]
4792+ fn allocate_zeroed ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocError > {
4793+ ( * * self ) . allocate_zeroed ( layout)
4794+ }
4795+
4796+ #[ inline]
4797+ unsafe fn deallocate ( & self , ptr : NonNull < u8 > , layout : Layout ) {
4798+ // SAFETY: the safety contract must be upheld by the caller
4799+ unsafe { ( * * self ) . deallocate ( ptr, layout) }
4800+ }
4801+
4802+ #[ inline]
4803+ unsafe fn grow (
4804+ & self ,
4805+ ptr : NonNull < u8 > ,
4806+ old_layout : Layout ,
4807+ new_layout : Layout ,
4808+ ) -> Result < NonNull < [ u8 ] > , AllocError > {
4809+ // SAFETY: the safety contract must be upheld by the caller
4810+ unsafe { ( * * self ) . grow ( ptr, old_layout, new_layout) }
4811+ }
4812+
4813+ #[ inline]
4814+ unsafe fn grow_zeroed (
4815+ & self ,
4816+ ptr : NonNull < u8 > ,
4817+ old_layout : Layout ,
4818+ new_layout : Layout ,
4819+ ) -> Result < NonNull < [ u8 ] > , AllocError > {
4820+ // SAFETY: the safety contract must be upheld by the caller
4821+ unsafe { ( * * self ) . grow_zeroed ( ptr, old_layout, new_layout) }
4822+ }
4823+
4824+ #[ inline]
4825+ unsafe fn shrink (
4826+ & self ,
4827+ ptr : NonNull < u8 > ,
4828+ old_layout : Layout ,
4829+ new_layout : Layout ,
4830+ ) -> Result < NonNull < [ u8 ] > , AllocError > {
4831+ // SAFETY: the safety contract must be upheld by the caller
4832+ unsafe { ( * * self ) . shrink ( ptr, old_layout, new_layout) }
4833+ }
4834+ }
0 commit comments