Trait TryFromTag

Source
pub trait TryFromTag<T, Discriminant: DiscriminantTag = ()>: Sized {
    type Error;

    // Required method
    fn try_from_tag(t: T) -> Result<Self, Self::Error>;
}
Expand description

Fallible version of FromTag.

Allows conversions that may fail, while still being disambiguated by a concrete discriminant.

§Type Parameters

  • T: Source type (may be generic or non-concrete).
  • Discriminant: A concrete marker type used to disambiguate conversions.

§Default Discriminant

  • Discriminant = (): uses the unit type as a default tag, meaning no additional disambiguation when a single interpretation exists.

Required Associated Types§

Required Methods§

Source

fn try_from_tag(t: T) -> Result<Self, Self::Error>

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 TryFromTag<Vec<()>, ManyTag> for ()

Trivial Many conversion for unit (always succeeds).

Implementors§

Source§

impl<Type, S> TryFromTag<Vec<Type>, ManyTag> for SumDynType<Type, S>
where Type: Delimited, S: Get<u32> + Clone + Debug + 'static,