Add a from_u32 function to EntityRef.
This eliminates the need for casting in common cases.
This commit is contained in:
@@ -100,6 +100,13 @@ macro_rules! entity_impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl $entity {
|
impl $entity {
|
||||||
|
/// Return the underlying index value as a `u32`.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn from_u32(x: u32) -> Self {
|
||||||
|
debug_assert!(x < $crate::__core::u32::MAX);
|
||||||
|
$entity(x)
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the underlying index value as a `u32`.
|
/// Return the underlying index value as a `u32`.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn as_u32(self) -> u32 {
|
pub fn as_u32(self) -> u32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user