OptionedConvert

Trait OptionedConvert 

Source
pub trait OptionedConvert<T>: Sized + Sealed<T>
where T: Optionable<Optioned = Self> + OptionableConvert,
{ // Provided methods fn from_optionable(value: T) -> Self { ... } fn try_into_optionable(self) -> Result<T, Error> { ... } }
Expand description

Sealed helper trait to transform from the perspective of the optioned type. Will be automatically implemented for every target <T as Optionable>:Optioned.

Provided Methods§

Source

fn from_optionable(value: T) -> Self

Gets an optioned variant with all fields set.

We cannot implement From from the stdlib as we need to implement this for various stdlib primitives and containers.

Source

fn try_into_optionable(self) -> Result<T, Error>

Try to build a full type from this optioned variant.

§Errors
  • If fields required by the full type are not set.

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<T, TOpt> OptionedConvert<T> for TOpt
where T: Optionable<Optioned = TOpt> + OptionableConvert,