summaryrefslogtreecommitdiff
path: root/ecs/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src')
-rw-r--r--ecs/src/component.rs3
-rw-r--r--ecs/src/component/storage.rs4
-rw-r--r--ecs/src/entity.rs1
-rw-r--r--ecs/src/lib.rs5
-rw-r--r--ecs/src/relationship.rs4
-rw-r--r--ecs/src/uid.rs3
6 files changed, 11 insertions, 9 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index e1f2858..513b31a 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -3,10 +3,10 @@ use std::fmt::Debug;
use seq_macro::seq;
-use crate::uid::Uid;
use crate::lock::{ReadGuard, WriteGuard};
use crate::system::{ComponentRef, ComponentRefMut, Input as SystemInput};
use crate::type_name::TypeName;
+use crate::uid::Uid;
use crate::{EntityComponent, World};
pub mod local;
@@ -50,6 +50,7 @@ pub trait Component: SystemInput + Any + TypeName
}
/// Returns whether this component is optional.
+ #[must_use]
fn is_optional() -> IsOptional
where
Self: Sized,
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs
index 141fea7..5c32e1e 100644
--- a/ecs/src/component/storage.rs
+++ b/ecs/src/component/storage.rs
@@ -393,9 +393,9 @@ impl Archetype
EntityIter { iter: self.entities.iter() }
}
- pub fn get_index_for_component(&self, component_id: &Uid) -> Option<usize>
+ pub fn get_index_for_component(&self, component_id: Uid) -> Option<usize>
{
- self.component_ids.get(component_id).copied()
+ self.component_ids.get(&component_id).copied()
}
fn push_entity(
diff --git a/ecs/src/entity.rs b/ecs/src/entity.rs
index fff66f5..3de9cd5 100644
--- a/ecs/src/entity.rs
+++ b/ecs/src/entity.rs
@@ -2,6 +2,7 @@ use linkme::distributed_slice;
use crate::World;
+#[allow(clippy::module_name_repetitions)]
#[macro_export]
macro_rules! static_entity {
($visibility: vis $ident: ident, $components: expr) => {
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index a643bec..78e526f 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -69,9 +69,7 @@ impl World
{
let mut world = Self::default();
- world
- .add_sole(Stats::default())
- .expect("World already has stats sole");
+ world.add_sole(Stats::default()).ok();
world
}
@@ -93,6 +91,7 @@ impl World
}
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
+ #[doc(hidden)]
pub fn create_entity_with_uid<Comps>(&self, components: Comps, entity_uid: Uid)
where
Comps: ComponentSequence + TupleReduce<TypeTransformComponentsToAddedEvents>,
diff --git a/ecs/src/relationship.rs b/ecs/src/relationship.rs
index 9f2a81e..259677b 100644
--- a/ecs/src/relationship.rs
+++ b/ecs/src/relationship.rs
@@ -169,7 +169,7 @@ where
.get_entity(*target)
.expect("Target entity is gone from archetype");
- let component_index = archetype.get_index_for_component(&ComponentT::id())?;
+ let component_index = archetype.get_index_for_component(ComponentT::id())?;
let component = ComponentRefMut::new(
entity
@@ -373,7 +373,7 @@ where
.get_entity(*target)
.expect("Target entity is gone from archetype");
- let component_index = archetype.get_index_for_component(&ComponentT::id())?;
+ let component_index = archetype.get_index_for_component(ComponentT::id())?;
let component = ComponentRef::new(
entity
diff --git a/ecs/src/uid.rs b/ecs/src/uid.rs
index 56d84f9..0e5d88a 100644
--- a/ecs/src/uid.rs
+++ b/ecs/src/uid.rs
@@ -29,10 +29,11 @@ impl Uid
let id_part = NEXT.fetch_add(1, Ordering::Relaxed);
Self {
- inner: ((id_part as u64) << 32) | kind as u64,
+ inner: (u64::from(id_part) << 32) | kind as u64,
}
}
+ #[must_use]
pub fn kind(&self) -> Kind
{
// SAFETY: The kind bits cannot be invalid since they are set using the Kind enum