Trait moveref::Emplace

source ·
pub trait Emplace<T>: Sized + Deref {
    type Output: Deref<Target = Self::Target>;

    // Required method
    fn try_emplace<N: TryNew<Output = T>>(
        new: N
    ) -> Result<Self::Output, N::Error>;

    // Provided method
    fn emplace<N: New<Output = T>>(new: N) -> Self::Output { ... }
}
Expand description

Operations for constructing New values into a Self::Output instance.

Required Associated Types§

source

type Output: Deref<Target = Self::Target>

Required Methods§

source

fn try_emplace<N: TryNew<Output = T>>(new: N) -> Result<Self::Output, N::Error>

Try to construct a New value into a fresh Self::Output instance.

§Errors

Should return Err if the new initializer fails with an error.

Provided Methods§

source

fn emplace<N: New<Output = T>>(new: N) -> Self::Output

Construct a New value into a fresh Self::Output instance.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Emplace<T> for Box<T>

§

type Output = Pin<Box<T>>

source§

fn try_emplace<N: TryNew<Output = T>>(new: N) -> Result<Self::Output, N::Error>

source§

impl<T> Emplace<T> for Rc<T>

§

type Output = Pin<Rc<T>>

source§

fn try_emplace<N: TryNew<Output = T>>(new: N) -> Result<Self::Output, N::Error>

source§

impl<T> Emplace<T> for Arc<T>

§

type Output = Pin<Arc<T>>

source§

fn try_emplace<N: TryNew<Output = T>>(new: N) -> Result<Self::Output, N::Error>

Implementors§