pub struct MaybeAlloc<A = TestAlloc<System>>where
A: GlobalAlloc,{ /* private fields */ }Expand description
MaybeAlloc is an implementation for GlobalAlloc , which occasionally fails to allocate.
It is a wrapper of another GlobalAlloc , and delegates the requests to the inner, however, sometimes fails to allocate
memory on purpose. i.e. MaybeAlloc::alloc can return null pointer before memory exhaustion.
The failure properbility is 1/16.
Trait Implementations§
Source§impl<A> Clone for MaybeAlloc<A>where
A: GlobalAlloc + Clone,
impl<A> Clone for MaybeAlloc<A>where
A: GlobalAlloc + Clone,
Source§impl<A> Debug for MaybeAlloc<A>where
A: GlobalAlloc + Debug,
impl<A> Debug for MaybeAlloc<A>where
A: GlobalAlloc + Debug,
Source§impl<A> Default for MaybeAlloc<A>where
A: GlobalAlloc + Default,
impl<A> Default for MaybeAlloc<A>where
A: GlobalAlloc + Default,
Source§impl<A> From<A> for MaybeAlloc<A>where
A: GlobalAlloc,
impl<A> From<A> for MaybeAlloc<A>where
A: GlobalAlloc,
Source§impl<A> GlobalAlloc for MaybeAlloc<A>where
A: GlobalAlloc,
impl<A> GlobalAlloc for MaybeAlloc<A>where
A: GlobalAlloc,
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout. Read moreAuto Trait Implementations§
impl<A> Freeze for MaybeAlloc<A>where
A: Freeze,
impl<A> RefUnwindSafe for MaybeAlloc<A>where
A: RefUnwindSafe,
impl<A> Send for MaybeAlloc<A>where
A: Send,
impl<A> Sync for MaybeAlloc<A>where
A: Sync,
impl<A> Unpin for MaybeAlloc<A>where
A: Unpin,
impl<A> UnwindSafe for MaybeAlloc<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more