pub trait PositionIndex: VariantCount {
// Required methods
fn index(&self) -> usize;
fn position_of(index: usize) -> Option<Self>
where Self: Sized;
}Expand description
Maps semantic variants to zero-based position indices.
VariantCount is 1-based, while PositionIndex is 0-based. As a result,
the maximum valid index is VariantCount::VARIANT_COUNT - 1.
Required Methods§
Sourcefn index(&self) -> usize
fn index(&self) -> usize
Returns the zero-based index for this variant, or None if the
variant must not participate in indexing.
Sourcefn position_of(index: usize) -> Option<Self>where
Self: Sized,
fn position_of(index: usize) -> Option<Self>where
Self: Sized,
Returns the variant for the given zero-based index, or None
if the index is out of range or non-semantic.
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.
Implementors§
impl PositionIndex for Disposition
impl PositionIndex for Polarity
impl PositionIndex for Ignore
Trivial implementation for marker type Ignore, representing a
single, non-variant position.