Skip to main content

EntityIdU32

Type Alias EntityIdU32 

Source
pub type EntityIdU32<Tag> = EntityIdU32Inner<PhantomData<Tag>>;
Expand description

A u32-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 EntityIdU32<Tag>(/* private fields */);

Implementations§

Source§

impl<Tag> EntityIdU32<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 EntityIdU32<Tag>

Source§

type Output = EntityIdU32Inner<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 EntityIdU32<Tag>

Source§

fn add_assign(&mut self, x: Delta)

Performs the += operation. Read more
Source§

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

Source§

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

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

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

Source§

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

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

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

Source§

fn from_idx(idx: usize) -> Self

Source§

fn to_idx(self) -> usize

Source§

impl<Tag: EntityTagArith> EntityIdArith for EntityIdU32<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 EntityIdU32<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 EntityIdU32<Tag>

Source§

type Output = EntityIdU32Inner<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 EntityIdU32<Tag>

Source§

fn sub_assign(&mut self, x: Delta)

Performs the -= operation. Read more