11use super :: { Buffer , UnmanagedBuffer } ;
22use alloc:: alloc:: Global ;
33use core:: {
4- alloc:: { AllocError , AllocRef , Layout } ,
4+ alloc:: { AllocError , Allocator , Layout } ,
55 marker:: { PhantomData , Unsize } ,
66 mem,
77 ops:: CoerceUnsized ,
@@ -41,12 +41,12 @@ impl<T> AllocatedBuffer<T> {
4141 }
4242}
4343
44- impl < T , A : ?Sized + AllocRef > AllocatedBuffer < T , A > {
44+ impl < T , A : ?Sized + Allocator > AllocatedBuffer < T , A > {
4545 fn allocate_in ( allocator : & A , init : Init ) -> Result < Self , AllocError > {
4646 let layout = Layout :: new :: < T > ( ) ;
4747 let ptr = match init {
48- Init :: Unspecified => allocator. alloc ( layout) ?,
49- Init :: Zeroed => allocator. alloc_zeroed ( layout) ?,
48+ Init :: Unspecified => allocator. allocate ( layout) ?,
49+ Init :: Zeroed => allocator. allocate_zeroed ( layout) ?,
5050 } ;
5151 unsafe { Ok ( Self :: from_raw ( ptr. as_non_null_ptr ( ) . cast ( ) ) ) }
5252 }
@@ -60,7 +60,7 @@ impl<T, A: ?Sized + AllocRef> AllocatedBuffer<T, A> {
6060 }
6161}
6262
63- impl < T , A : ?Sized + AllocRef > AllocatedBuffer < [ T ] , A > {
63+ impl < T , A : ?Sized + Allocator > AllocatedBuffer < [ T ] , A > {
6464 fn capacity_from_bytes ( bytes : usize ) -> usize {
6565 debug_assert_ne ! ( mem:: size_of:: <T >( ) , 0 ) ;
6666 bytes / mem:: size_of :: < T > ( )
@@ -73,8 +73,8 @@ impl<T, A: ?Sized + AllocRef> AllocatedBuffer<[T], A> {
7373 let layout = Layout :: array :: < T > ( len) . map_err ( |_| AllocError ) ?;
7474 alloc_guard ( layout. size ( ) ) . map_err ( |_| AllocError ) ?;
7575 let ptr = match init {
76- Init :: Unspecified => allocator. alloc ( layout) ?,
77- Init :: Zeroed => allocator. alloc_zeroed ( layout) ?,
76+ Init :: Unspecified => allocator. allocate ( layout) ?,
77+ Init :: Zeroed => allocator. allocate_zeroed ( layout) ?,
7878 } ;
7979
8080 NonNull :: slice_from_raw_parts (
@@ -94,7 +94,7 @@ impl<T, A: ?Sized + AllocRef> AllocatedBuffer<[T], A> {
9494 }
9595}
9696
97- impl < T : ?Sized , A : ?Sized + AllocRef > Buffer < T > for AllocatedBuffer < T , A > {
97+ impl < T : ?Sized , A : ?Sized + Allocator > Buffer < T > for AllocatedBuffer < T , A > {
9898 type ExternalData = A ;
9999
100100 fn as_ptr ( & self , _data : & Self :: ExternalData ) -> * const T {
@@ -106,7 +106,7 @@ impl<T: ?Sized, A: ?Sized + AllocRef> Buffer<T> for AllocatedBuffer<T, A> {
106106 }
107107}
108108
109- impl < T , A : ?Sized + AllocRef > Buffer < mem:: MaybeUninit < T > > for AllocatedBuffer < T , A > {
109+ impl < T , A : ?Sized + Allocator > Buffer < mem:: MaybeUninit < T > > for AllocatedBuffer < T , A > {
110110 type ExternalData = A ;
111111
112112 fn as_ptr ( & self , _data : & Self :: ExternalData ) -> * const mem:: MaybeUninit < T > {
@@ -118,7 +118,7 @@ impl<T, A: ?Sized + AllocRef> Buffer<mem::MaybeUninit<T>> for AllocatedBuffer<T,
118118 }
119119}
120120
121- impl < T , A : ?Sized + AllocRef > Buffer < [ mem:: MaybeUninit < T > ] > for AllocatedBuffer < [ T ] , A > {
121+ impl < T , A : ?Sized + Allocator > Buffer < [ mem:: MaybeUninit < T > ] > for AllocatedBuffer < [ T ] , A > {
122122 type ExternalData = A ;
123123
124124 fn as_ptr ( & self , _data : & Self :: ExternalData ) -> * const [ mem:: MaybeUninit < T > ] {
@@ -130,12 +130,12 @@ impl<T, A: ?Sized + AllocRef> Buffer<[mem::MaybeUninit<T>]> for AllocatedBuffer<
130130 }
131131}
132132
133- impl < T : ?Sized , A : AllocRef > UnmanagedBuffer < T > for AllocatedBuffer < T , A > {
133+ impl < T : ?Sized , A : Allocator > UnmanagedBuffer < T > for AllocatedBuffer < T , A > {
134134 unsafe fn free_unchecked ( & mut self , allocator : & Self :: ExternalData ) {
135135 let size = mem:: size_of_val ( self . ptr . as_ref ( ) ) ;
136136 let align = mem:: align_of_val ( self . ptr . as_ref ( ) ) ;
137137 let layout = Layout :: from_size_align_unchecked ( size, align) ;
138- allocator. dealloc ( self . ptr . cast ( ) , layout) ;
138+ allocator. deallocate ( self . ptr . cast ( ) , layout) ;
139139 }
140140}
141141
@@ -148,7 +148,7 @@ const fn alloc_guard(alloc_size: usize) -> Result<(), AllocError> {
148148 }
149149}
150150
151- impl < T : ?Sized + Unsize < U > , U : ?Sized , A : AllocRef > CoerceUnsized < AllocatedBuffer < U , A > >
151+ impl < T : ?Sized + Unsize < U > , U : ?Sized , A : Allocator > CoerceUnsized < AllocatedBuffer < U , A > >
152152 for AllocatedBuffer < T , A >
153153{
154154}
0 commit comments