TryExtract

Trait TryExtract 

Source
pub trait TryExtract<A: Access<T>, T>: Access<T> + Sized {
    // Required method
    fn try_extract(
        self,
    ) -> Result<(A, <A as Access<T>>::RemainderFrom<Self>), Self>;
}
Expand description

Trait for runtime checked extraction that may fail.

Returns Ok with (extracted, remainder) on success, or Err with original value on failure.

Most conversions delegate to Extract and always succeed; only Option<T> → T can fail when the value is None.

Required Methods§

Source

fn try_extract(self) -> Result<(A, <A as Access<T>>::RemainderFrom<Self>), Self>

Try to extract a value into target type and remainder parts.

§Errors

Returns Err with the original value if the extraction cannot be performed (e.g., when trying to convert Option<T> to T but the value is None).

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.

Implementations on Foreign Types§

Source§

impl<T> TryExtract<Option<T>, T> for PhantomData<T>

Source§

fn try_extract( self, ) -> Result<(Option<T>, <Option<T> as Access<T>>::RemainderFrom<Self>), Self>

Source§

impl<T> TryExtract<PhantomData<T>, T> for PhantomData<T>

Source§

fn try_extract( self, ) -> Result<(PhantomData<T>, <PhantomData<T> as Access<T>>::RemainderFrom<Self>), Self>

Source§

impl<T, A: Access<T>> TryExtract<A, T> for Option<T>

Source§

fn try_extract(self) -> Result<(A, <A as Access<T>>::RemainderFrom<Self>), Self>

Implementors§

Source§

impl<T, A: Access<T>> TryExtract<A, T> for T