Reify

Trait Reify 

Source
pub trait Reify<L: LifetimeList = L0, Group: ?Sized = DefaultGroup>: Tagged<Group, Tag = Self::UsedTag> {
    type Reified: ?Sized;
    type Lifetimes: LifetimeList + ToHoleList<HoleList = Self::UsedNeededLifetimes> + Prefix<L>;
    type UsedTag: Tag<NeededLifetimes = Self::UsedNeededLifetimes> + WithLt<Self::Lifetimes, Reified = Self::Reified>;
    type UsedNeededLifetimes: FirstNLifetimes<Self::Lifetimes, Output = Self::Lifetimes> + FirstNLifetimes<L, Output = Self::Lifetimes> + HoleList;
}
Expand description

Type level operation to reify a tag into it’s associated type.

Do not attempt to implement this manually. This trait is implemented on anything that implements Tagged with a valid tag.

The L generic is some list of lifetimes to combine with the tag to form the reified type. By default, it is a list with no lifetimes. The lifetime list length does not need to match that of the tag. The first N lifetimes of the list will be used in the reify operation.

For most uses, the default Group of DefaultGroup will be enough. In cases where Self is expected to be tagged by another group it can be changed.

The extra associated types are provided to reduce the needed trait bounds for some usages. They fully connect the tag with the reified type in a self consistent way.

§Examples

use ty_tag::{tag, TagOf, Reify, l};

fn with_lt<'a>() {
    // Combine the tag of &str with lifetime 'a to form the &'a str lifetime containing type.
    reify::<'a, TagOf<&str>, &'a str>();

    // The type itself also (usually) works with Reify.
    reify::<'a, &'static str, &'a str>();

    // Even the lifetime containing form can be used.
    reify::<'static, &'a str, &'static str>();
}
with_lt();

fn reify<'a, T: Reify<l!['a], Reified = U>, U>() {}

Required Associated Types§

Source

type Reified: ?Sized

The reified type.

This is taken from the tag’s WithLt implementation.

Source

type Lifetimes: LifetimeList + ToHoleList<HoleList = Self::UsedNeededLifetimes> + Prefix<L>

The lifetimes used to reify the type.

This will be some prefix of the full L list of lifetimes.

Source

type UsedTag: Tag<NeededLifetimes = Self::UsedNeededLifetimes> + WithLt<Self::Lifetimes, Reified = Self::Reified>

The tag used for the reification.

Reify is implemented on anything with an implementation of Tagged. This type is the Tagged::Tag.

Source

type UsedNeededLifetimes: FirstNLifetimes<Self::Lifetimes, Output = Self::Lifetimes> + FirstNLifetimes<L, Output = Self::Lifetimes> + HoleList

The needed lifetimes from the tag.

This is the Tag::NeededLifetimes of Tagged::Tag. It is also the same length as the Reify::Lifetimes list.

Implementors§

Source§

impl<T, L, Group: ?Sized> Reify<L, Group> for T

Source§

type Reified = <<T as Tagged<Group>>::Tag as WithLt<<<<T as Tagged<Group>>::Tag as Tag>::NeededLifetimes as FirstNLifetimes<L>>::Output>>::Reified

Source§

type Lifetimes = <<<T as Tagged<Group>>::Tag as Tag>::NeededLifetimes as FirstNLifetimes<L>>::Output

Source§

type UsedTag = <T as Tagged<Group>>::Tag

Source§

type UsedNeededLifetimes = <<T as Tagged<Group>>::Tag as Tag>::NeededLifetimes