Trait IntoTag

Source
pub trait IntoTag<R, Discriminant: DiscriminantTag = ()> {
    // Required method
    fn into_tag(self) -> R;
}
Expand description

Converts self into another representation under a given discriminant.

This is the method-based counterpart to FromTag. It exists for ergonomic use, similar to how Into complements From.

The additional discriminant ensures that conversions remain unambiguous even when source and target types are not fully concrete.

§Type Parameters

  • R: Target 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 Methods§

Source

fn into_tag(self) -> R

Implementations on Foreign Types§

Source§

impl IntoTag<Vec<()>, ManyTag> for ()

Converts unit into an empty Many representation.

Source§

fn into_tag(self) -> Vec<()>

Implementors§

Source§

impl<T, U, Tag> IntoTag<U, Tag> for T
where U: FromTag<T, Tag>, Tag: DiscriminantTag,

Blanket implementation of IntoTag for any type that implements FromTag.

This mirrors the relationship between Into and From, while preserving disambiguation via the discriminant.

The discriminant ensures that even when T and U are not fully concrete, the conversion remains uniquely identifiable and does not violate coherence.

Source§

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