Skip to main content

TryNew

Trait TryNew 

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§

type Value

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

Required Methods§

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

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

Implementations on Foreign Types§

§

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".

§

type Value = T

§

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

Implementors§

§

impl<T> TryNew for Box<T>

§

type Value = T