moveit::new

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§