1010use std:: {
1111 alloc:: { AllocError , Allocator , Layout } ,
1212 cell:: { Cell , UnsafeCell } ,
13+ mem,
1314 ptr:: { self , addr_of, NonNull } ,
1415 thread:: { self , ThreadId } ,
15- mem,
1616} ;
1717
1818const BIN_SIZE : usize = 8 ;
@@ -33,7 +33,7 @@ impl MyBin {
3333 }
3434 // Cast the *entire* thing to a raw pointer to not restrict its provenance.
3535 let bin = self as * const MyBin ;
36- let base_ptr = UnsafeCell :: raw_get ( unsafe { addr_of ! ( ( * bin) . memory ) } ) . cast :: < usize > ( ) ;
36+ let base_ptr = UnsafeCell :: raw_get ( unsafe { addr_of ! ( ( * bin) . memory) } ) . cast :: < usize > ( ) ;
3737 let ptr = unsafe { NonNull :: new_unchecked ( base_ptr. add ( top) ) } ;
3838 self . top . set ( top + 1 ) ;
3939 Some ( ptr. cast ( ) )
@@ -64,22 +64,14 @@ impl MyAllocator {
6464 MyAllocator {
6565 thread_id,
6666 bins : Box :: new (
67- [ MyBin {
68- top : Cell :: new ( 0 ) ,
69- thread_id,
70- memory : UnsafeCell :: default ( ) ,
71- } ; 1 ] ,
67+ [ MyBin { top : Cell :: new ( 0 ) , thread_id, memory : UnsafeCell :: default ( ) } ; 1 ] ,
7268 ) ,
7369 }
7470 }
7571
7672 // Pretends to be expensive finding a suitable bin for the layout.
7773 fn find_bin ( & self , layout : Layout ) -> Option < & MyBin > {
78- if layout == Layout :: new :: < usize > ( ) {
79- Some ( & self . bins [ 0 ] )
80- } else {
81- None
82- }
74+ if layout == Layout :: new :: < usize > ( ) { Some ( & self . bins [ 0 ] ) } else { None }
8375 }
8476}
8577
0 commit comments