Skip to main content

EntityIdU16

Type Alias EntityIdU16 

Source
pub type EntityIdU16<Tag> = EntityIdU16Inner<PhantomData<Tag>>;
Expand description

A u16-sized id type.

The Tag generic parameter allows distinguishing IDs that are semantically of a different type.

The Tag must implement EntityTag. While implementing that trait, you may also specify how the IDs with that tag should be displayed.

§Formatting

When formatting the ID with either the Debug ({:?}) or Display ({}) specifier, the numeric value will be prefixed by EntityTag::PREFIX. However, this can be suppressed by using the {:#} format specifier, i.e. Display with the alternate flag set.

struct ChipTag;
type ChipId = EntityIdU16<ChipTag>;
impl EntityTag for ChipTag {
    const PREFIX: &'static str = "CHIP";
}

let n = ChipId::from_idx(3);
assert_eq!(format!("{}", n), "CHIP3");
assert_eq!(format!("{:?}", n), "CHIP3");
assert_eq!(format!("{:#}", n), "3");

Aliased Type§

pub struct EntityIdU16<Tag>(/* private fields */);

Implementations§

Source§

impl<Tag> EntityIdU16<Tag>

Source

pub const fn from_idx_const(idx: usize) -> Self

Source

pub const fn to_idx_const(self) -> usize

Trait Implementations§

Source§

impl<Tag: EntityTagArith, Delta: EntityDelta> Add<Delta> for EntityIdU16<Tag>

Source§

type Output = EntityIdU16Inner<PhantomData<Tag>>

The resulting type after applying the + operator.
Source§

fn add(self, x: Delta) -> Self

Performs the + operation. Read more
Source§

impl<Tag: EntityTagArith, Delta: EntityDelta> AddAssign<Delta> for EntityIdU16<Tag>

Source§

fn add_assign(&mut self, x: Delta)

Performs the += operation. Read more
Source§

impl<Tag: EntityTag> Debug for EntityIdU16<Tag>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Tag: EntityTag> Display for EntityIdU16<Tag>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Tag: EntityTag> EntityId for EntityIdU16<Tag>

Source§

fn from_idx(idx: usize) -> Self

Source§

fn to_idx(self) -> usize

Source§

impl<Tag: EntityTagArith> EntityIdArith for EntityIdU16<Tag>

Source§

fn range_until(self, other: Self) -> EntityRange<Self>

Source§

fn range_until_inclusive(self, other: Self) -> EntityRange<Self>

Source§

fn range_around(self, down: usize, up: usize) -> EntityRange<Self>

Source§

fn range_up(self, len: usize) -> EntityRange<Self>

Source§

fn range_down(self, len: usize) -> EntityRange<Self>

Source§

impl<Tag: EntityTagArith> Sub for EntityIdU16<Tag>

Source§

type Output = isize

The resulting type after applying the - operator.
Source§

fn sub(self, x: Self) -> isize

Performs the - operation. Read more
Source§

impl<Tag: EntityTagArith, Delta: EntityDelta> Sub<Delta> for EntityIdU16<Tag>

Source§

type Output = EntityIdU16Inner<PhantomData<Tag>>

The resulting type after applying the - operator.
Source§

fn sub(self, x: Delta) -> Self

Performs the - operation. Read more
Source§

impl<Tag: EntityTagArith, Delta: EntityDelta> SubAssign<Delta> for EntityIdU16<Tag>

Source§

fn sub_assign(&mut self, x: Delta)

Performs the -= operation. Read more