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 Specializer
s
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§
Sourceconst IS_CANONICAL: bool
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§
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.