deallocate_zeroed/
default.rs

1use super::*;
2
3/// A wrapper around an allocator `A` that provides a default implementation of
4/// `DeallocateZeroed` that simply forwards the pointer to `A::deallocate`.
5pub struct DefaultDeallocateZeroed<A>(pub A);
6
7unsafe impl<A> Allocator for DefaultDeallocateZeroed<A>
8where
9    A: Allocator,
10{
11    #[inline]
12    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
13        self.0.allocate(layout)
14    }
15
16    #[inline]
17    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
18        self.0.deallocate(ptr, layout);
19    }
20}
21
22impl<T> DeallocateZeroed for DefaultDeallocateZeroed<T> where T: Allocator {}