waffle::entity

Trait EntityRef

Source
pub trait EntityRef:
    Clone
    + Copy
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Hash {
    // Required methods
    fn new(value: usize) -> Self;
    fn index(self) -> usize;
    fn invalid() -> Self;

    // Provided methods
    fn is_valid(self) -> bool { ... }
    fn is_invalid(self) -> bool { ... }
    fn maybe_index(self) -> Option<usize> { ... }
}
Expand description

An index into an index-space of entities.

Required Methods§

Source

fn new(value: usize) -> Self

Create a new type-safe index value from a known index.

Source

fn index(self) -> usize

Get the index value of this type-safe index. Must be a valid index (will panic otherwise).

Source

fn invalid() -> Self

A sentinel invalid value.

Provided Methods§

Source

fn is_valid(self) -> bool

Is this index a valid index (not equal to Self::invalid())?

Source

fn is_invalid(self) -> bool

Is this index an invalid index (equal to Self::invalid())?

Source

fn maybe_index(self) -> Option<usize>

Turn a valid index into Some(index), and an invalid index into None.

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§