AllocateError

Struct AllocateError 

Source
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>

Source

pub fn handle(self) -> !

Handles the error by calling handle_alloc_error if the alloc feature is enabled, or panicking otherwise.

Source

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.

Source

pub fn into_parts(self) -> (Value, AllocateError)

Seperates the value from the error.

Source

pub fn unwrap_result<T>(result: Result<T, Self>) -> T

Unwraps the result using Self::handle when it is an error.

Source

pub const fn layout(&self) -> Option<Layout>

Gets the layout for the allocation.

If this returns None, the layout calculation failed.

Source

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

Source

pub const fn with_value<Value>(self, value: Value) -> AllocateError<Value>

Places a value into the error.

Source

pub const fn new_layout(source: LayoutError) -> Self

Create a new error from a LayoutError.

Source

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>

Source§

fn clone(&self) -> AllocateError<Value>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AllocateError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AllocateError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for AllocateError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<Value> From<AllocateError<Value>> for AllocError

Source§

fn from(_value: AllocateError<Value>) -> Self

Converts to this type from the input type.
Source§

impl From<LayoutError> for AllocateError

Source§

fn from(value: LayoutError) -> Self

Converts to this type from the input type.
Source§

impl<Value: PartialEq> PartialEq for AllocateError<Value>

Source§

fn eq(&self, other: &AllocateError<Value>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Value: Eq> Eq for AllocateError<Value>

Source§

impl<Value> StructuralPartialEq for AllocateError<Value>

Auto Trait Implementations§

§

impl<Value> Freeze for AllocateError<Value>
where Value: Freeze,

§

impl<Value> RefUnwindSafe for AllocateError<Value>
where Value: RefUnwindSafe,

§

impl<Value> Send for AllocateError<Value>
where Value: Send,

§

impl<Value> Sync for AllocateError<Value>
where Value: Sync,

§

impl<Value> Unpin for AllocateError<Value>
where Value: Unpin,

§

impl<Value> UnwindSafe for AllocateError<Value>
where Value: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.