Trait moveit::new::TryNew

source ·
pub unsafe trait TryNew: Sized {
    type Output;
    type Error;

    // Required method
    unsafe fn try_new(
        self,
        this: Pin<&mut MaybeUninit<Self::Output>>
    ) -> Result<(), Self::Error>;

    // Provided method
    fn with<F>(self, post: F) -> TryWith<Self, F> { ... }
}
Expand description

An in-place constructor for a particular type, which can potentially fail.

Emplacing a TryNew may allocate even when construction fails; prefer to use Result<impl New> when possible, instead.

Safety

TryNew::try_new() must leave its destination argument in a valid, initialized state when it returns Ok.

Required Associated Types§

source

type Output

The type to construct.

source

type Error

The error the construction operation may return.

Required Methods§

source

unsafe fn try_new( self, this: Pin<&mut MaybeUninit<Self::Output>> ) -> Result<(), Self::Error>

Try to construct a new value using the arguments stored in self.

Safety

this must be freshly-created memory; this function must not be used to mutate a previously-pinned pointer that has had self: Pin functions called on it.

Provided Methods§

source

fn with<F>(self, post: F) -> TryWith<Self, F>

Adds a post-construction operation.

This function is analogous to New::with(); see its documentation for more information.

Note: The return value of this function should not be relied upon; a future version will replace it with impl TryNew.

Implementors§

source§

impl<N: New> TryNew for N

§

type Output = <N as New>::Output

§

type Error = Infallible