Trait PositionIndex

Source
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§

Source

fn index(&self) -> usize

Returns the zero-based index for this variant, or None if the variant must not participate in indexing.

Source

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§

Source§

impl PositionIndex for Disposition

Source§

impl PositionIndex for Polarity

Source§

impl PositionIndex for Ignore

Trivial implementation for marker type Ignore, representing a single, non-variant position.