SpecializerKey

Trait SpecializerKey 

Source
pub trait SpecializerKey:
    Clone
    + Hash
    + Eq {
    type Canonical: Hash + Eq;

    const IS_CANONICAL: bool;
}
Expand description

Defines a type that is able to be used as a key for Specializers

Most types should implement this trait with the included derive macro.
This generates a "canonical" key type, with IS_CANONICAL = true, and Canonical = Self

§What’s a “canonical” key?

The specialization API memoizes pipelines based on the hash of each key, but this can still produce duplicates. For example, if one used a list of vertex attributes as a key, even if all the same attributes were present they could be in any order. In each case, though the keys would be “different” they would produce the same pipeline.

To address this, during specialization keys are processed into a canonical (or “standard”) form that represents the actual descriptor that was produced. In the previous example, that would be the final VertexBufferLayout contained by the pipeline descriptor. This new key is used by Variants to perform additional checks for duplicates, but only if required. If a key is canonical from the start, then there’s no need.

For implementors: the main property of a canonical key is that if two keys hash differently, they should nearly always produce different descriptors.

Required Associated Constants§

Source

const IS_CANONICAL: bool

Denotes whether this key is canonical or not. This should only be true if and only if Canonical = Self.

Required Associated Types§

Source

type Canonical: Hash + Eq

The canonical key type to convert this into during specialization.

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 SpecializerKey for ()

Source§

impl<T0: SpecializerKey, T1: SpecializerKey> SpecializerKey for (T0, T1)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey> SpecializerKey for (T0, T1, T2)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey> SpecializerKey for (T0, T1, T2, T3)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey, T7: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey, T7: SpecializerKey, T8: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey, T7: SpecializerKey, T8: SpecializerKey, T9: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey, T7: SpecializerKey, T8: SpecializerKey, T9: SpecializerKey, T10: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Source§

impl<T0: SpecializerKey, T1: SpecializerKey, T2: SpecializerKey, T3: SpecializerKey, T4: SpecializerKey, T5: SpecializerKey, T6: SpecializerKey, T7: SpecializerKey, T8: SpecializerKey, T9: SpecializerKey, T10: SpecializerKey, T11: SpecializerKey> SpecializerKey for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

impl<T: SpecializerKey> SpecializerKey for (T,)

Implementors§