pub struct FailOnSize {
pub min_fail_bytes: usize,
}Expand description
Policy that fails any allocation whose requested size is at least
min_fail_bytes, and permits smaller ones.
Models an allocator that can satisfy small requests but not large
ones — exercising the size-dependent OOM branch (a slab that rejects
over-stride requests, a fixed arena that has room for scratch but
not a bulk buffer). Stateless and Copy.
Fields§
§min_fail_bytes: usizeSmallest request size, in bytes, that is forced to fail (inclusive).
Implementations§
Source§impl FailOnSize
impl FailOnSize
Sourcepub const fn new(min_fail_bytes: usize) -> FailOnSize
pub const fn new(min_fail_bytes: usize) -> FailOnSize
Construct a policy that fails allocations of min_fail_bytes
bytes or larger.
Trait Implementations§
Source§impl AllocFaultPolicy for FailOnSize
impl AllocFaultPolicy for FailOnSize
Source§fn should_fail(&self, layout: NonZeroLayout) -> bool
fn should_fail(&self, layout: NonZeroLayout) -> bool
Return
true to force the pending allocation of layout to
fail with AllocError; return false to
let it proceed to the inner allocator. Read moreSource§impl Clone for FailOnSize
impl Clone for FailOnSize
Source§fn clone(&self) -> FailOnSize
fn clone(&self) -> FailOnSize
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for FailOnSize
Auto Trait Implementations§
impl Freeze for FailOnSize
impl RefUnwindSafe for FailOnSize
impl Send for FailOnSize
impl Sync for FailOnSize
impl Unpin for FailOnSize
impl UnsafeUnpin for FailOnSize
impl UnwindSafe for FailOnSize
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