summaryrefslogtreecommitdiff
path: root/engine-ecs/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine-ecs/src')
-rw-r--r--engine-ecs/src/actions.rs33
-rw-r--r--engine-ecs/src/component.rs17
-rw-r--r--engine-ecs/src/component/storage.rs30
-rw-r--r--engine-ecs/src/entity.rs2
-rw-r--r--engine-ecs/src/error.rs21
-rw-r--r--engine-ecs/src/lib.rs51
-rw-r--r--engine-ecs/src/lock.rs4
-rw-r--r--engine-ecs/src/phase.rs24
-rw-r--r--engine-ecs/src/query.rs1
-rw-r--r--engine-ecs/src/query/flexible.rs9
-rw-r--r--engine-ecs/src/query/term.rs2
-rw-r--r--engine-ecs/src/sole.rs10
-rw-r--r--engine-ecs/src/system.rs3
-rw-r--r--engine-ecs/src/tuple.rs2
-rw-r--r--engine-ecs/src/util/array_vec.rs5
15 files changed, 126 insertions, 88 deletions
diff --git a/engine-ecs/src/actions.rs b/engine-ecs/src/actions.rs
index 5eaa24e..d079a85 100644
--- a/engine-ecs/src/actions.rs
+++ b/engine-ecs/src/actions.rs
@@ -21,6 +21,9 @@ impl Actions<'_>
{
/// Queues up a entity to spawn at the end of the current tick, returning the [`Uid`]
/// that the entity will have.
+ ///
+ /// # Panics
+ /// This function will panic if any component in `bundle` is a [`Sole`].
pub fn spawn<BundleT: Bundle>(&mut self, bundle: BundleT) -> Uid
{
let new_entity_uid = Uid::new_unique();
@@ -45,6 +48,9 @@ impl Actions<'_>
///
/// In addition to the given components, the entity will have a [`EntityName`]
/// component containing `name`.
+ ///
+ /// # Panics
+ /// This function will panic if any component in `bundle` is a [`Sole`].
pub fn spawn_named<BundleT: Bundle>(
&mut self,
name: impl Into<Cow<'static, str>>,
@@ -105,6 +111,9 @@ impl Actions<'_>
}
/// Queues up adding component(s) to a entity at the end of the current tick.
+ ///
+ /// # Panics
+ /// This function will panic if any component in `bundle` is a [`Sole`].
pub fn add_components<BundleT: Bundle>(&mut self, entity_uid: Uid, bundle: BundleT)
{
debug_assert!(!entity_uid.is_pair());
@@ -198,7 +207,7 @@ impl Actions<'_>
pub fn set_pair_target(
&mut self,
entity_id: Uid,
- pair: Pair<Uid, Uid>,
+ pair: &Pair<Uid, Uid>,
new_target_id: Uid,
)
{
@@ -215,8 +224,8 @@ impl Actions<'_>
let pair_id = pair.id();
self.action_queue.push(Action::SetPair {
- entity_id: entity_id,
- pair_id: pair_id,
+ entity_id,
+ pair_id,
new_pair: Pair::builder()
.relation_id(pair_id.relation())
.target_id(new_target_id)
@@ -235,7 +244,7 @@ impl Actions<'_>
pub fn set_pair_target_and_data<NewTarget>(
&mut self,
entity_id: Uid,
- pair: Pair<Uid, Uid>,
+ pair: &Pair<Uid, Uid>,
new_target: NewTarget,
) where
NewTarget: Component,
@@ -252,8 +261,8 @@ impl Actions<'_>
let pair_id = pair.id();
self.action_queue.push(Action::SetPair {
- entity_id: entity_id,
- pair_id: pair_id,
+ entity_id,
+ pair_id,
new_pair: Pair::builder()
.relation_id(pair_id.relation())
.target_as_data(new_target)
@@ -272,7 +281,7 @@ impl Actions<'_>
pub fn set_pair_relation(
&mut self,
entity_id: Uid,
- pair: Pair<Uid, Uid>,
+ pair: &Pair<Uid, Uid>,
new_relation_id: Uid,
)
{
@@ -289,8 +298,8 @@ impl Actions<'_>
let pair_id = pair.id();
self.action_queue.push(Action::SetPair {
- entity_id: entity_id,
- pair_id: pair_id,
+ entity_id,
+ pair_id,
new_pair: Pair::builder()
.relation_id(new_relation_id)
.target_id(pair_id.target())
@@ -309,7 +318,7 @@ impl Actions<'_>
pub fn set_pair_relation_and_data<NewRelation>(
&mut self,
entity_id: Uid,
- pair: Pair<Uid, Uid>,
+ pair: &Pair<Uid, Uid>,
new_relation: NewRelation,
) where
NewRelation: Component,
@@ -326,8 +335,8 @@ impl Actions<'_>
let pair_id = pair.id();
self.action_queue.push(Action::SetPair {
- entity_id: entity_id,
- pair_id: pair_id,
+ entity_id,
+ pair_id,
new_pair: Pair::builder()
.relation_as_data(new_relation)
.target_id(pair_id.target())
diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs
index c76c48e..400b12c 100644
--- a/engine-ecs/src/component.rs
+++ b/engine-ecs/src/component.rs
@@ -101,6 +101,10 @@ impl<'comp, DataT: 'static> Handle<'comp, DataT>
impl<'comp> Handle<'comp, dyn Any>
{
+ /// Creates a handle to a untyped component.
+ ///
+ /// # Errors
+ /// Will return `Err` if acquiring the component's lock fails.
pub fn new_any(
entity_component_ref: &EntityComponentRef<'comp>,
) -> Result<Self, HandleError>
@@ -164,6 +168,10 @@ impl<'comp, DataT: 'static> HandleMut<'comp, DataT>
impl<'comp> HandleMut<'comp, dyn Any>
{
+ /// Creates a handle to a untyped component.
+ ///
+ /// # Errors
+ /// Will return `Err` if acquiring the component's lock fails.
pub fn new_any(
entity_component_ref: &EntityComponentRef<'comp>,
world: &'comp World,
@@ -182,7 +190,7 @@ impl<'comp> HandleMut<'comp, dyn Any>
}
}
-impl<'comp, DataT: ?Sized + 'static> HandleMut<'comp, DataT>
+impl<DataT: ?Sized + 'static> HandleMut<'_, DataT>
{
pub fn set_changed(&self)
{
@@ -249,6 +257,13 @@ pub struct Parts
impl Parts
{
+ /// Creates components parts from the component information stored in
+ /// `component_info`.
+ ///
+ /// # Panics
+ /// This function will panic if the type ID of the value in `data` does not equal
+ /// to the type ID stored in `component_info`.
+ #[must_use]
pub fn from_component_info(component_info: &Info, id: Uid, data: Box<dyn Any>)
-> Self
{
diff --git a/engine-ecs/src/component/storage.rs b/engine-ecs/src/component/storage.rs
index 5746bea..b208a90 100644
--- a/engine-ecs/src/component/storage.rs
+++ b/engine-ecs/src/component/storage.rs
@@ -185,7 +185,7 @@ impl Storage
.collect(),
});
- let found_archetypes = self.find_all_archetype_with_comps(&search_terms);
+ let found_archetypes = self.find_all_archetype_with_comps(search_terms);
return ArchetypeRefIter {
storage: self,
@@ -688,16 +688,12 @@ impl<'component_storage, const TERM_CAP: usize> Iterator
let mut traversal_results =
ArrayVec::<TraversalResult, TERM_CAP>::default();
- if do_traversals(
+ do_traversals(
self.storage,
archetype,
&self.search_terms.traverse,
&mut traversal_results,
- )
- .is_none()
- {
- return None;
- };
+ )?;
Some((archetype, traversal_results))
})
@@ -705,8 +701,9 @@ impl<'component_storage, const TERM_CAP: usize> Iterator
return Some((pre_iter_archetype, pre_iter_traversal_results));
}
- let (archetype, traversal_results) = loop {
- match self.dfs_iter.streaming_find(|res| {
+ let (archetype, traversal_results) =
+ loop {
+ match self.dfs_iter.streaming_find(|res| {
matches!(
res,
ArchetypeAddEdgeDfsIterResult::AddEdge { .. }
@@ -735,12 +732,10 @@ impl<'component_storage, const TERM_CAP: usize> Iterator
add_edge_archetype,
&self.search_terms.traverse,
&mut traversal_results,
- )
- .is_none()
- {
+ ).is_none() {
self.dfs_iter.pop();
continue;
- };
+ }
break (add_edge_archetype, traversal_results);
}
@@ -769,9 +764,8 @@ impl<'component_storage, const TERM_CAP: usize> Iterator
},
);
- let found = self.find_edges_of_imaginary_archetype(
- add_edge_archetype_comps.clone(),
- );
+ let found =
+ self.find_edges_of_imaginary_archetype(&add_edge_archetype_comps);
self.dfs_iter.push((
BorrowedOrOwned::Owned(Archetype::new(
@@ -785,7 +779,7 @@ impl<'component_storage, const TERM_CAP: usize> Iterator
unreachable!();
}
}
- };
+ };
Some((archetype, traversal_results))
}
@@ -795,7 +789,7 @@ impl<const TERM_CAP: usize> ArchetypeRefIter<'_, '_, TERM_CAP>
{
fn find_edges_of_imaginary_archetype(
&self,
- imaginary_archetype_comps: ArrayVec<Uid, 32>,
+ imaginary_archetype_comps: &ArrayVec<Uid, 32>,
) -> Vec<(Uid, ArchetypeEdges)>
{
self.storage
diff --git a/engine-ecs/src/entity.rs b/engine-ecs/src/entity.rs
index ba85956..7515f73 100644
--- a/engine-ecs/src/entity.rs
+++ b/engine-ecs/src/entity.rs
@@ -298,7 +298,7 @@ impl Declaration
pub const fn new(spawn_func: fn(&mut World)) -> Self
{
Self {
- uid: LazyLock::new(|| Uid::new_unique()),
+ uid: LazyLock::new(Uid::new_unique),
spawn_func,
}
}
diff --git a/engine-ecs/src/error.rs b/engine-ecs/src/error.rs
index 5ce5632..67d26d6 100644
--- a/engine-ecs/src/error.rs
+++ b/engine-ecs/src/error.rs
@@ -38,7 +38,8 @@ impl Error
Self { inner: anyhow::Error::msg(message) }
}
- pub fn context<Ctx>(self, context: Ctx) -> Error
+ #[must_use]
+ pub fn context<Ctx>(self, context: Ctx) -> Self
where
Ctx: Display + Send + Sync + 'static,
{
@@ -112,10 +113,12 @@ where
pub trait Context<T>
{
+ #[allow(clippy::missing_errors_doc)]
fn context<Ctx>(self, context: Ctx) -> Result<T, Error>
where
Ctx: Display + Send + Sync + 'static;
+ #[allow(clippy::missing_errors_doc)]
fn with_context<Ctx>(self, context_func: impl FnOnce() -> Ctx) -> Result<T, Error>
where
Ctx: Display + Send + Sync + 'static;
@@ -157,7 +160,7 @@ impl<T> Context<T> for Result<T, Error>
}
}
-pub type HandlerFn = fn(&World, Error, Metadata);
+pub type HandlerFn = fn(&World, Error, &Metadata);
/// Error metadata.
#[derive(Debug)]
@@ -187,7 +190,7 @@ impl Display for SourceKind
}
}
-pub fn err_handler_panic(_world: &World, err: Error, err_metadata: Metadata)
+pub fn err_handler_panic(_world: &World, err: Error, err_metadata: &Metadata)
{
std::panic::panic_any(err.context(format!(
"Error occurred in {} '{}'",
@@ -195,7 +198,8 @@ pub fn err_handler_panic(_world: &World, err: Error, err_metadata: Metadata)
)));
}
-pub fn err_handler_log_error(_world: &World, err: Error, err_metadata: Metadata)
+#[allow(clippy::needless_pass_by_value)]
+pub fn err_handler_log_error(_world: &World, err: Error, err_metadata: &Metadata)
{
tracing::error!(
"Error occurred in {} '{}': {err:#}",
@@ -232,18 +236,17 @@ pub(crate) fn set_panic_hook()
));
}
- println!("");
+ println!();
}));
}
fn get_current_os_thread_id() -> u64
{
cfg_select! {
- target_os = "linux" => {
- (unsafe { libc::gettid() }) as u64
- }
+ target_os = "linux" => u64::from((unsafe { libc::gettid() }).cast_unsigned()),
windows => {
- (unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() }) as u64
+ (unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() })
+ as u64
}
_ => {
compile_error!("Unsupported target OS");
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs
index aef374c..9ea03f0 100644
--- a/engine-ecs/src/lib.rs
+++ b/engine-ecs/src/lib.rs
@@ -1,4 +1,5 @@
#![deny(clippy::all, clippy::pedantic)]
+#![allow(clippy::needless_pass_by_value)]
use std::any::Any;
use std::borrow::Cow;
@@ -175,7 +176,7 @@ impl World
self.create_ent(
entity_uid,
components_parts,
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
@@ -197,10 +198,14 @@ impl World
self.create_ent(
entity_uid,
components_parts.chain([EntityName { name: name.into() }.into_parts()]),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
+ /// Adds a component to an entity.
+ ///
+ /// # Panics
+ /// This function will panic if the component is a [`Sole`].
pub fn add_component(&mut self, entity_id: Uid, component_parts: ComponentParts)
{
assert!(
@@ -214,7 +219,7 @@ impl World
[component_parts],
&mut self.data.component_storage,
&EventSubmitter::new(&self.data.new_events),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
@@ -248,7 +253,7 @@ impl World
sole.into_parts(),
EntityName { name: name.into() }.into_parts(),
],
- ComponentAddingFlags { allow_soles: true },
+ &ComponentAddingFlags { allow_soles: true },
);
Ok(())
@@ -271,7 +276,7 @@ impl World
.into_iter()
.map(IntoComponentParts::into_parts),
),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
system_callbacks.on_created(self, SystemMetadata { ent_id });
@@ -455,7 +460,7 @@ impl World
&mut self,
entity_uid: Uid,
components: impl IntoIterator<Item = ComponentParts>,
- flags: ComponentAddingFlags,
+ flags: &ComponentAddingFlags,
)
{
debug_assert!(!entity_uid.is_pair());
@@ -503,11 +508,11 @@ impl World
(self.error_handler)(
self,
err,
- ErrorMetadata {
+ &ErrorMetadata {
source_name: system.system.name(),
source_kind: ErrorSourceKind::System,
},
- )
+ );
}
}
}
@@ -588,7 +593,7 @@ impl World
.queue
.write_nonblock()
.unwrap_or_else(|err| {
- panic!("Failed to take read-write action queue lock: {err}",);
+ panic!("Failed to take read-write action queue lock: {err}");
});
for action in action_queue_lock.drain(..) {
@@ -609,7 +614,7 @@ impl World
components,
&mut self.data.component_storage,
&EventSubmitter::new(&self.data.new_events),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
Action::Despawn(entity_id) => {
@@ -627,7 +632,7 @@ impl World
components,
&mut self.data.component_storage,
&EventSubmitter::new(&self.data.new_events),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
Action::RemoveComponents(entity_uid, component_ids) => {
@@ -646,7 +651,7 @@ impl World
"Cannot set pair of a non-existant entity"
);
continue;
- };
+ }
let _ = self
.data
@@ -658,7 +663,7 @@ impl World
[new_pair],
&mut self.data.component_storage,
&EventSubmitter::new(&self.data.new_events),
- ComponentAddingFlags { allow_soles: false },
+ &ComponentAddingFlags { allow_soles: false },
);
}
Action::Stop => {
@@ -673,7 +678,7 @@ impl World
components: impl IntoIterator<Item = ComponentParts>,
component_storage: &mut ComponentStorage,
event_submitter: &EventSubmitter<'_>,
- flags: ComponentAddingFlags,
+ flags: &ComponentAddingFlags,
)
{
let component_iter = components.into_iter();
@@ -687,7 +692,7 @@ impl World
let comp_id = component_parts.id;
let comp_name = component_parts.name;
- let comp_type_id = (&*component_parts.data).type_id();
+ let comp_type_id = (*component_parts.data).type_id();
if let Err(err) = component_storage.add_entity_component(
entity_uid,
@@ -774,12 +779,10 @@ impl World
if comp_ent_archetype.contains_component_with_exact_id(ComponentInfo::id()) {
return;
}
- } else {
- if let Err(EntityAlreadyExistsError) =
- component_storage.create_entity(comp_id)
- {
- unreachable!();
- }
+ } else if let Err(EntityAlreadyExistsError) =
+ component_storage.create_entity(comp_id)
+ {
+ unreachable!();
}
let comp_info_parts = comp_info.into_parts();
@@ -805,7 +808,7 @@ impl World
// This error is never returned by add_entity_component
unreachable!();
}
- };
+ }
}
fn remove_entity_components(
@@ -891,11 +894,11 @@ impl World
(self.error_handler)(
self,
err,
- ErrorMetadata {
+ &ErrorMetadata {
source_name: observer.system.name(),
source_kind: ErrorSourceKind::Observer,
},
- )
+ );
}
}
}
diff --git a/engine-ecs/src/lock.rs b/engine-ecs/src/lock.rs
index 3db29e8..685eb8f 100644
--- a/engine-ecs/src/lock.rs
+++ b/engine-ecs/src/lock.rs
@@ -105,7 +105,7 @@ impl<'guard, Value: ?Sized> ReadGuard<'guard, Value>
MappedReadGuard {
inner: RwLockReadGuard::map(inner, func),
- value_type_name: value_type_name,
+ value_type_name,
}
}
@@ -203,7 +203,7 @@ impl<'guard, Value: ?Sized> WriteGuard<'guard, Value>
MappedWriteGuard {
inner: RwLockWriteGuard::map(inner, func),
- value_type_name: value_type_name,
+ value_type_name,
}
}
diff --git a/engine-ecs/src/phase.rs b/engine-ecs/src/phase.rs
index 78428c4..64c1593 100644
--- a/engine-ecs/src/phase.rs
+++ b/engine-ecs/src/phase.rs
@@ -1,4 +1,11 @@
use crate::{declare_entity, Component, World};
+#[cfg(debug_assertions)]
+use crate::{
+ entity::Name as EntityName,
+ pair::{ChildOf, Pair, Wildcard},
+ query::term::With,
+ Query,
+};
#[derive(Debug, Default, Clone, Copy, Component)]
pub struct Phase;
@@ -35,11 +42,7 @@ pub(crate) struct HasSystem;
#[cfg(debug_assertions)]
pub(crate) fn check_parents(
- phase_query: crate::query::Query<(
- crate::pair::Pair<crate::pair::ChildOf, crate::pair::Wildcard>,
- Option<&crate::entity::Name>,
- crate::query::term::With<Phase>,
- )>,
+ phase_query: Query<(Pair<ChildOf, Wildcard>, Option<&EntityName>, With<Phase>)>,
)
{
for (child_of, ent_name) in &phase_query {
@@ -47,25 +50,22 @@ pub(crate) fn check_parents(
tracing::warn!(
phase_entity = ent_name
.as_ref()
- .map(|ent_name| ent_name.name.as_ref())
- .unwrap_or("<unnamed>"),
+ .map_or("<unnamed>", |ent_name| ent_name.name.as_ref()),
"Parent entity of phase entity does not exist"
);
continue;
};
if !parent_ent.has_component(Phase::id()) {
- let parent_ent_name = parent_ent.get::<crate::entity::Name>();
+ let parent_ent_name = parent_ent.get::<EntityName>();
tracing::warn!(
phase_entity = ent_name
.as_ref()
- .map(|ent_name| ent_name.name.as_ref())
- .unwrap_or("<unnamed>"),
+ .map_or("<unnamed>", |ent_name| ent_name.name.as_ref()),
parent_entity = parent_ent_name
.as_ref()
- .map(|parent_ent_name| parent_ent_name.name.as_ref())
- .unwrap_or("<unnamed>"),
+ .map_or("<unnamed>", |parent_ent_name| parent_ent_name.name.as_ref()),
"Parent entity of phase entity is not a phase (missing Phase component)"
);
}
diff --git a/engine-ecs/src/query.rs b/engine-ecs/src/query.rs
index c323092..0dd8d49 100644
--- a/engine-ecs/src/query.rs
+++ b/engine-ecs/src/query.rs
@@ -110,6 +110,7 @@ impl<'world, TermsT> Query<'world, TermsT>
}
}
+ #[must_use]
pub fn into_flexible_query(self) -> FlexibleQuery<'world, MAX_TERM_CNT>
{
self.inner
diff --git a/engine-ecs/src/query/flexible.rs b/engine-ecs/src/query/flexible.rs
index 0198fb4..06b0e79 100644
--- a/engine-ecs/src/query/flexible.rs
+++ b/engine-ecs/src/query/flexible.rs
@@ -23,7 +23,7 @@ impl<'world, const TERM_CAP: usize> Query<'world, TERM_CAP>
'world: 'this,
{
Iter {
- archetype_iter: self
+ inner: self
.world
.data
.component_storage
@@ -61,7 +61,7 @@ where
pub struct Iter<'query, const TERM_CAP: usize>
{
- archetype_iter: ArchetypeRefIter<'query, 'query, TERM_CAP>,
+ inner: ArchetypeRefIter<'query, 'query, TERM_CAP>,
current: Option<(
&'query Archetype,
ArrayVec<TraversalResult, TERM_CAP>,
@@ -70,8 +70,9 @@ pub struct Iter<'query, const TERM_CAP: usize>
world: &'query World,
}
-impl<'query, const TERM_CAP: usize> Iter<'query, TERM_CAP>
+impl<const TERM_CAP: usize> Iter<'_, TERM_CAP>
{
+ #[must_use]
pub fn traversal_results(&self) -> Option<&[TraversalResult]>
{
self.current
@@ -92,7 +93,7 @@ impl<'query, const TERM_CAP: usize> Iterator for Iter<'query, TERM_CAP>
}
}
- let (archetype, traversal_results) = self.archetype_iter.next()?;
+ let (archetype, traversal_results) = self.inner.next()?;
self.current = Some((archetype, traversal_results, archetype.entities()));
diff --git a/engine-ecs/src/query/term.rs b/engine-ecs/src/query/term.rs
index 453a750..980ee87 100644
--- a/engine-ecs/src/query/term.rs
+++ b/engine-ecs/src/query/term.rs
@@ -47,7 +47,6 @@ where
_term_metadata: TermMetadata,
) -> Self::Fields
{
- ()
}
}
@@ -78,7 +77,6 @@ where
_term_metadata: TermMetadata,
) -> Self::Fields
{
- ()
}
}
diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs
index 1e287d3..4047b48 100644
--- a/engine-ecs/src/sole.rs
+++ b/engine-ecs/src/sole.rs
@@ -61,7 +61,10 @@ impl<'world, SoleT> Single<'world, SoleT>
where
SoleT: Sole,
{
- /// Returns a reference to `SoleT` if it exists. If not, returns `Err`.
+ /// Returns a reference to `SoleT`.
+ ///
+ /// # Errors
+ /// Returns `Err` if the sole does not exist.
pub fn get(&self) -> Result<&SoleT, DoesNotExistError>
{
self.sole
@@ -69,7 +72,10 @@ where
.ok_or_else(|| DoesNotExistError { name: type_name::<SoleT>() })
}
- /// Returns a mutable reference to `SoleT` if it exists. If not, returns `Err`.
+ /// Returns a mutable reference to `SoleT`.
+ ///
+ /// # Errors
+ /// Returns `Err` if the sole does not exist.
pub fn get_mut(&mut self) -> Result<&mut SoleT, DoesNotExistError>
{
self.sole
diff --git a/engine-ecs/src/system.rs b/engine-ecs/src/system.rs
index 5395b14..e0eac57 100644
--- a/engine-ecs/src/system.rs
+++ b/engine-ecs/src/system.rs
@@ -92,6 +92,7 @@ impl TypeErased
///
/// # Safety
/// `world_data` must live at least as long as the [`World`] the system belongs to.
+ #[allow(clippy::missing_errors_doc)]
pub unsafe fn run(
&self,
world: &World,
@@ -102,6 +103,7 @@ impl TypeErased
(self.run)(world, metadata, evt)
}
+ #[must_use]
pub fn name(&self) -> &'static str
{
self.name
@@ -118,6 +120,7 @@ impl Debug for TypeErased
pub trait ReturnValue
{
+ #[allow(clippy::missing_errors_doc)]
fn into_result(self) -> Result<(), Error>;
}
diff --git a/engine-ecs/src/tuple.rs b/engine-ecs/src/tuple.rs
index a2073b1..990842b 100644
--- a/engine-ecs/src/tuple.rs
+++ b/engine-ecs/src/tuple.rs
@@ -294,7 +294,7 @@ seq!(I in 0..16 {
match index {
#(
I => {
- assert!(TypeId::of::<Element>() == TypeId::of::<Elem~I>());
+ assert_eq!(TypeId::of::<Element>(), TypeId::of::<Elem~I>());
// SAFETY: It is checked above that the type is correct
Some(unsafe { &mut *(&raw mut self.I).cast::<Element>() })
diff --git a/engine-ecs/src/util/array_vec.rs b/engine-ecs/src/util/array_vec.rs
index 3e3344c..bfcc158 100644
--- a/engine-ecs/src/util/array_vec.rs
+++ b/engine-ecs/src/util/array_vec.rs
@@ -24,6 +24,8 @@ impl<Item, const CAPACITY: usize> ArrayVec<Item, CAPACITY>
self.len == 0
}
+ /// # Panics
+ /// This function will panic if no more space is available.
pub fn push(&mut self, item: Item)
{
assert!(self.len < CAPACITY);
@@ -33,6 +35,9 @@ impl<Item, const CAPACITY: usize> ArrayVec<Item, CAPACITY>
self.len += 1;
}
+ /// # Panics
+ /// This function will panic if the index is out of bounds or if no more space is
+ /// available.
pub fn insert(&mut self, index: usize, item: Item)
{
assert!(index <= self.len);