diff options
author | HampusM <hampus@hampusmat.com> | 2025-04-22 18:06:59 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-04-22 18:06:59 +0200 |
commit | fb47933690dfb54206e9f136902671b19ddd34e0 (patch) | |
tree | ffdb6640ea896b69b0267a9526657b9ed454184f /ecs/src/uid.rs | |
parent | d9ac86a1f6ec541a399794f9f81381753cfea5f6 (diff) |
refactor(ecs): fix clippy lints
Diffstat (limited to 'ecs/src/uid.rs')
-rw-r--r-- | ecs/src/uid.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ecs/src/uid.rs b/ecs/src/uid.rs index 6c97649..feed62c 100644 --- a/ecs/src/uid.rs +++ b/ecs/src/uid.rs @@ -54,8 +54,12 @@ impl Uid } } + /// Returns a new pair UID. + /// + /// # Panics + /// Will panic if either the given relation or target is a pair UID. #[must_use] - pub fn new_pair(params: PairParams) -> Self + pub fn new_pair(params: &PairParams) -> Self { assert_ne!( params.relation.kind(), @@ -102,6 +106,7 @@ impl Uid /// /// # Panics /// Will panic if this `Uid` is not a pair. + #[must_use] pub fn relation_component(&self) -> Self { assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair"); @@ -112,6 +117,7 @@ impl Uid } } + #[must_use] pub fn has_same_relation_as(&self, other: Self) -> bool { self.relation() == other.relation() @@ -121,6 +127,7 @@ impl Uid /// /// # Panics /// Will panic if this `Uid` is not a pair. + #[must_use] pub fn relation_entity(&self) -> Self { assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair"); @@ -135,6 +142,7 @@ impl Uid /// /// # Panics /// Will panic if this `Uid` is not a pair. + #[must_use] pub fn target_component(&self) -> Self { assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair"); @@ -149,6 +157,7 @@ impl Uid /// /// # Panics /// Will panic if this `Uid` is not a pair. + #[must_use] pub fn target_entity(&self) -> Self { assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair"); @@ -159,7 +168,7 @@ impl Uid } } - fn relation(&self) -> u32 + fn relation(self) -> u32 { let Ok(relation) = u32::try_from(self.inner.field_get(RELATION_BITS)) else { unreachable!("Uid relation does not fit in u32"); |