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>
impl<Tag> EntityIdU16<Tag>
pub const fn from_idx_const(idx: usize) -> Self
pub const fn to_idx_const(self) -> usize
Trait Implementations§
Source§impl<Tag: EntityTagArith, Delta: EntityDelta> Add<Delta> for EntityIdU16<Tag>
impl<Tag: EntityTagArith, Delta: EntityDelta> Add<Delta> for EntityIdU16<Tag>
Source§impl<Tag: EntityTagArith, Delta: EntityDelta> AddAssign<Delta> for EntityIdU16<Tag>
impl<Tag: EntityTagArith, Delta: EntityDelta> AddAssign<Delta> for EntityIdU16<Tag>
Source§fn add_assign(&mut self, x: Delta)
fn add_assign(&mut self, x: Delta)
Performs the
+= operation. Read moreSource§impl<Tag: EntityTag> Debug for EntityIdU16<Tag>
impl<Tag: EntityTag> Debug for EntityIdU16<Tag>
Source§impl<Tag: EntityTag> Display for EntityIdU16<Tag>
impl<Tag: EntityTag> Display for EntityIdU16<Tag>
Source§impl<Tag: EntityTag> EntityId for EntityIdU16<Tag>
impl<Tag: EntityTag> EntityId for EntityIdU16<Tag>
Source§impl<Tag: EntityTagArith> EntityIdArith for EntityIdU16<Tag>
impl<Tag: EntityTagArith> EntityIdArith for EntityIdU16<Tag>
fn range_until(self, other: Self) -> EntityRange<Self>
fn range_until_inclusive(self, other: Self) -> EntityRange<Self>
fn range_around(self, down: usize, up: usize) -> EntityRange<Self>
fn range_up(self, len: usize) -> EntityRange<Self>
fn range_down(self, len: usize) -> EntityRange<Self>
Source§impl<Tag: EntityTagArith> Sub for EntityIdU16<Tag>
impl<Tag: EntityTagArith> Sub for EntityIdU16<Tag>
Source§impl<Tag: EntityTagArith, Delta: EntityDelta> Sub<Delta> for EntityIdU16<Tag>
impl<Tag: EntityTagArith, Delta: EntityDelta> Sub<Delta> for EntityIdU16<Tag>
Source§impl<Tag: EntityTagArith, Delta: EntityDelta> SubAssign<Delta> for EntityIdU16<Tag>
impl<Tag: EntityTagArith, Delta: EntityDelta> SubAssign<Delta> for EntityIdU16<Tag>
Source§fn sub_assign(&mut self, x: Delta)
fn sub_assign(&mut self, x: Delta)
Performs the
-= operation. Read more