TrySplit

Trait TrySplit 

Source
pub trait TrySplit<To: Presence>: Presence {
    // Required method
    fn try_split<T>(
        value: Self::Output<T>,
    ) -> Result<SplitResult<To, Self, T>, Self::Output<T>>
       where Self: Sized;
}
Expand description

Trait for runtime checked splitting that may fail.

Returns Ok with (selected, remainder) on success, or Err with original value on failure. Automatically succeeds when Split is implemented (blanket impl); only fails when Optional → Present with None.

Required Methods§

Source

fn try_split<T>( value: Self::Output<T>, ) -> Result<SplitResult<To, Self, T>, Self::Output<T>>
where Self: Sized,

Try to split a value into selected and remainder parts.

§Errors

Returns Err with the original value if the split cannot be performed (e.g., when trying to convert Optional to Present 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.

Implementors§

Source§

impl TrySplit<Present> for Optional

Source§

impl<From, To: Presence> TrySplit<To> for From
where From: Split<To> + Presence,