Skip to main content

TryNew

Trait TryNew 

Source
pub trait TryNew {
    type Value;

    // Required method
    fn try_new(value: Self::Value) -> Result<Self, OutOfMemory>
       where Self: Sized;
}
Expand description

Extension trait providing fallible allocation for types like Arc<T> and Box<T>.

Required Associated Types§

Source

type Value

The inner T type that is getting wrapped into an Arc<T> or Box<T>.

Required Methods§

Source

fn try_new(value: Self::Value) -> Result<Self, OutOfMemory>
where Self: Sized,

Allocate a new Self, returning Err(OutOfMemory) on allocation failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> TryNew for Arc<T>

XXX: Stable Rust doesn’t actually give us any method to build fallible allocation for Arc<T>, so this is only actually fallible when using nightly Rust and setting RUSTFLAGS="--cfg arc_try_new".

Source§

type Value = T

Source§

fn try_new(value: T) -> Result<Self, OutOfMemory>
where Self: Sized,

Source§

impl<T> TryNew for Box<T>

Source§

type Value = T

Source§

fn try_new(value: T) -> Result<Self, OutOfMemory>
where Self: Sized,

Implementors§