From 614c0df0537567c75f781df7affc091a4a466226 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 15 Nov 2022 20:38:32 +0000 Subject: clippy --- azalea-world/src/entity/attributes.rs | 5 ++--- azalea-world/src/entity/mod.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'azalea-world/src/entity') diff --git a/azalea-world/src/entity/attributes.rs b/azalea-world/src/entity/attributes.rs index 1050615c..f7e9682e 100644 --- a/azalea-world/src/entity/attributes.rs +++ b/azalea-world/src/entity/attributes.rs @@ -40,9 +40,8 @@ impl AttributeInstance { AttributeModifierOperation::MultiplyBase => total += self.base * modifier.amount, _ => {} } - match modifier.operation { - AttributeModifierOperation::MultiplyTotal => total *= 1.0 + modifier.amount, - _ => {} + if let AttributeModifierOperation::MultiplyTotal = modifier.operation { + total *= 1.0 + modifier.amount } } total diff --git a/azalea-world/src/entity/mod.rs b/azalea-world/src/entity/mod.rs index 63147ced..540bfeed 100644 --- a/azalea-world/src/entity/mod.rs +++ b/azalea-world/src/entity/mod.rs @@ -270,10 +270,19 @@ impl EntityData { &self.pos } + /// Convert this &mut self into a (mutable) pointer. + /// + /// # Safety + /// The entity MUST exist while this pointer exists. pub unsafe fn as_ptr(&mut self) -> NonNull { NonNull::new_unchecked(self as *mut EntityData) } + /// Convert this &self into a (mutable) pointer. + /// + /// # Safety + /// The entity MUST exist while this pointer exists. You also must not + /// modify the data inside the pointer. pub unsafe fn as_const_ptr(&self) -> NonNull { // this is cursed NonNull::new_unchecked(self as *const EntityData as *mut EntityData) -- cgit v1.2.3