summaryrefslogtreecommitdiff
path: root/ecs/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src')
-rw-r--r--ecs/src/component/storage/archetype.rs9
-rw-r--r--ecs/src/lib.rs6
-rw-r--r--ecs/src/lock.rs4
-rw-r--r--ecs/src/pair.rs7
-rw-r--r--ecs/src/query.rs8
-rw-r--r--ecs/src/query/flexible.rs1
-rw-r--r--ecs/src/system/initializable.rs6
-rw-r--r--ecs/src/util/array_vec.rs4
8 files changed, 24 insertions, 21 deletions
diff --git a/ecs/src/component/storage/archetype.rs b/ecs/src/component/storage/archetype.rs
index 8e1ff05..788794a 100644
--- a/ecs/src/component/storage/archetype.rs
+++ b/ecs/src/component/storage/archetype.rs
@@ -370,11 +370,10 @@ impl Id
}
for comp_id in component_id_iter {
- if prev_component_id.is_some_and(|prev_comp_id| *comp_id < prev_comp_id) {
- panic!(
- "Cannot create archetype ID from a unsorted component metadata list"
- );
- }
+ assert!(
+ prev_component_id.is_none_or(|prev_comp_id| *comp_id >= prev_comp_id),
+ "Cannot create archetype ID from a unsorted component metadata list"
+ );
prev_component_id = Some(*comp_id);
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 302fe55..f5fa9f6 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -218,9 +218,9 @@ impl World
.component_storage
.get_entity_archetype(entity_id)?;
- let entity = archetype
- .get_entity_by_id(entity_id)
- .expect("Should exist since archetype was found by entity id");
+ let Some(entity) = archetype.get_entity_by_id(entity_id) else {
+ unreachable!("Should exist since archetype was found by entity id");
+ };
Some(EntityHandle::new(archetype, entity))
}
diff --git a/ecs/src/lock.rs b/ecs/src/lock.rs
index abdf995..689070b 100644
--- a/ecs/src/lock.rs
+++ b/ecs/src/lock.rs
@@ -90,7 +90,7 @@ impl<'guard, Value> ReadGuard<'guard, Value>
// The 'inner' field cannot be moved out of ReadGuard in a normal way since
// ReadGuard implements Drop
- let inner = unsafe { std::ptr::read(&this.inner) };
+ let inner = unsafe { std::ptr::read(&raw const this.inner) };
forget(this);
match RwLockReadGuard::try_map(inner, func) {
@@ -169,7 +169,7 @@ impl<'guard, Value> WriteGuard<'guard, Value>
// The 'inner' field cannot be moved out of ReadGuard in a normal way since
// ReadGuard implements Drop
- let inner = unsafe { std::ptr::read(&this.inner) };
+ let inner = unsafe { std::ptr::read(&raw const this.inner) };
forget(this);
match RwLockWriteGuard::try_map(inner, func) {
diff --git a/ecs/src/pair.rs b/ecs/src/pair.rs
index 3dc9f36..7b5f54a 100644
--- a/ecs/src/pair.rs
+++ b/ecs/src/pair.rs
@@ -280,6 +280,7 @@ impl WildcardTargetHandle<'_>
/// # Panics
/// Will panic if:
/// - The component is mutably borrowed elsewhere
+ #[must_use]
pub fn get_component<ComponentData>(
&self,
) -> Option<ComponentHandle<'_, ComponentData>>
@@ -297,7 +298,7 @@ impl WildcardTargetHandle<'_>
);
}
},
- |handle| Some(handle),
+ Some,
)
}
@@ -307,6 +308,7 @@ impl WildcardTargetHandle<'_>
/// # Panics
/// Will panic if:
/// - The component is borrowed elsewhere
+ #[must_use]
pub fn get_component_mut<ComponentData>(
&self,
) -> Option<ComponentHandleMut<'_, ComponentData>>
@@ -326,7 +328,7 @@ impl WildcardTargetHandle<'_>
);
}
},
- |handle| Some(handle),
+ Some,
)
}
}
@@ -365,6 +367,7 @@ pub struct Wildcard(Infallible);
impl Wildcard
{
+ #[must_use]
pub fn uid() -> Uid
{
Uid::wildcard()
diff --git a/ecs/src/query.rs b/ecs/src/query.rs
index 1f281f1..dc9b036 100644
--- a/ecs/src/query.rs
+++ b/ecs/src/query.rs
@@ -48,7 +48,7 @@ where
Iter {
world: self.inner.world(),
- iter: self.inner.iter(),
+ inner: self.inner.iter(),
comps_pd: PhantomData,
}
}
@@ -86,7 +86,7 @@ where
Iter {
world: self.inner.world(),
- iter: func(self.inner.iter()),
+ inner: func(self.inner.iter()),
comps_pd: PhantomData,
}
}
@@ -446,7 +446,7 @@ where
EntityHandleIter: Iterator<Item = EntityHandle<'query>>,
{
world: &'world World,
- iter: EntityHandleIter,
+ inner: EntityHandleIter,
comps_pd: PhantomData<FieldTerms>,
}
@@ -461,7 +461,7 @@ where
fn next(&mut self) -> Option<Self::Item>
{
- let entity_handle = self.iter.next()?;
+ let entity_handle = self.inner.next()?;
Some(FieldTerms::get_fields(&entity_handle, self.world))
}
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs
index 50997b4..0caaa27 100644
--- a/ecs/src/query/flexible.rs
+++ b/ecs/src/query/flexible.rs
@@ -39,6 +39,7 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT>
}
}
+ #[must_use]
pub fn world(&self) -> &'world World
{
self.world
diff --git a/ecs/src/system/initializable.rs b/ecs/src/system/initializable.rs
index 40fbb0f..b6ec8e8 100644
--- a/ecs/src/system/initializable.rs
+++ b/ecs/src/system/initializable.rs
@@ -56,8 +56,8 @@ where
type Return = Accumulator::WithElementAtEnd<ParamT>;
}
-impl<'world, ParamT, Accumulator, SystemT>
- AppendInitializableParam<'world, Accumulator, ParamT, SystemT> for ()
+impl<ParamT, Accumulator, SystemT>
+ AppendInitializableParam<'_, Accumulator, ParamT, SystemT> for ()
where
Accumulator: Tuple,
{
@@ -101,7 +101,7 @@ seq!(C in 1..16 {
impl_initializable_param_tuple!(C);
});
-impl<'world, SystemT> ParamTuple<'world, SystemT> for ()
+impl<SystemT> ParamTuple<'_, SystemT> for ()
{
type Inputs = ();
diff --git a/ecs/src/util/array_vec.rs b/ecs/src/util/array_vec.rs
index a37b1f9..5d0aac9 100644
--- a/ecs/src/util/array_vec.rs
+++ b/ecs/src/util/array_vec.rs
@@ -45,8 +45,8 @@ impl<Item, const CAPACITY: usize> ArrayVec<Item, CAPACITY>
unsafe {
std::ptr::copy(
- &self.items[index],
- &mut self.items[index + 1],
+ &raw const self.items[index],
+ &raw mut self.items[index + 1],
self.len - index,
);
}