pub struct AllocateError<Value = ()> { /* private fields */ }Expand description
The error type returned when an allocation fails.
This can either be from an arithmetic error when calculating the layout or from an allocator when allocating.
Implementations§
Source§impl<Value> AllocateError<Value>
impl<Value> AllocateError<Value>
Sourcepub fn handle(self) -> !
pub fn handle(self) -> !
Handles the error by calling handle_alloc_error if the alloc feature is enabled, or panicking otherwise.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Gets the value held in the error.
This is usually from attempting to insert the value into a list.
Sourcepub fn into_parts(self) -> (Value, AllocateError)
pub fn into_parts(self) -> (Value, AllocateError)
Seperates the value from the error.
Sourcepub fn unwrap_result<T>(result: Result<T, Self>) -> T
pub fn unwrap_result<T>(result: Result<T, Self>) -> T
Unwraps the result using Self::handle when it is an error.
Sourcepub const fn layout(&self) -> Option<Layout>
pub const fn layout(&self) -> Option<Layout>
Gets the layout for the allocation.
If this returns None, the layout calculation failed.
Sourcepub fn map<U, F>(self, f: F) -> AllocateError<U>where
F: FnOnce(Value) -> U,
pub fn map<U, F>(self, f: F) -> AllocateError<U>where
F: FnOnce(Value) -> U,
Applies a function f to the value.
This maps from an AllocateError<Value> to an AllocateError<U>.
Source§impl AllocateError
impl AllocateError
Sourcepub const fn with_value<Value>(self, value: Value) -> AllocateError<Value>
pub const fn with_value<Value>(self, value: Value) -> AllocateError<Value>
Places a value into the error.
Sourcepub const fn new_layout(source: LayoutError) -> Self
pub const fn new_layout(source: LayoutError) -> Self
Create a new error from a LayoutError.
Sourcepub const fn new_alloc(source: AllocError, layout: Layout) -> Self
pub const fn new_alloc(source: AllocError, layout: Layout) -> Self
Create a new error from a AllocError and the Layout that could not be allocated.
Trait Implementations§
Source§impl<Value: Clone> Clone for AllocateError<Value>
impl<Value: Clone> Clone for AllocateError<Value>
Source§fn clone(&self) -> AllocateError<Value>
fn clone(&self) -> AllocateError<Value>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more