From 97f973d685baf389dcde08044dd3dfb7ba556050 Mon Sep 17 00:00:00 2001
From: HampusM <hampus@hampusmat.com>
Date: Sat, 6 Apr 2024 14:17:30 +0200
Subject: refactor(ecs): fix Clippy lints

---
 ecs/src/actions.rs |  3 +++
 ecs/src/event.rs   |  1 +
 ecs/src/lib.rs     | 15 +++++++++++++++
 ecs/src/lock.rs    |  8 ++++++++
 4 files changed, 27 insertions(+)

(limited to 'ecs/src')

diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs
index c58b06b..ea4837a 100644
--- a/ecs/src/actions.rs
+++ b/ecs/src/actions.rs
@@ -15,6 +15,9 @@ pub struct Actions<'world>
 impl<'world> Actions<'world>
 {
     /// Adds a spawning a new entity to the action queue.
+    ///
+    /// # Panics
+    /// Will panic if a mutable internal lock cannot be acquired.
     pub fn spawn<Comps: ComponentSequence>(&mut self, components: Comps)
     {
         self.world_data
diff --git a/ecs/src/event.rs b/ecs/src/event.rs
index 01d9d80..9545318 100644
--- a/ecs/src/event.rs
+++ b/ecs/src/event.rs
@@ -19,6 +19,7 @@ pub struct Id
 impl Id
 {
     /// Returns the id of a [`Event`];
+    #[must_use]
     pub fn of<EventT: Event>() -> Self
     {
         Self { inner: TypeId::of::<EventT>() }
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index fc97d42..5273b67 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -63,6 +63,10 @@ impl World
         Self::default()
     }
 
+    /// Creates a new entity with the given components.
+    ///
+    /// # Panics
+    /// Will panic if mutable internal lock cannot be acquired.
     pub fn create_entity<Comps>(&mut self, components: Comps)
     where
         Comps: ComponentSequence,
@@ -122,6 +126,9 @@ impl World
     }
 
     /// Peforms the actions that have been queued up using [`Actions`].
+    ///
+    /// # Panics
+    /// Will panic if a mutable internal lock cannot be acquired.
     pub fn perform_queued_actions(&self)
     {
         for action in self
@@ -157,6 +164,10 @@ impl World
         }
     }
 
+    /// A event loop which runs until a stop is issued with [`Flags::stop`].
+    ///
+    /// # Panics
+    /// Will panic if a internal lock cannot be acquired.
     pub fn event_loop<EventSeq: EventSequence>(&self)
     {
         let event_seq = EventSeq::ids();
@@ -262,6 +273,7 @@ impl<'world, Comps> Query<'world, Comps>
 where
     Comps: ComponentSequence,
 {
+    #[must_use]
     pub fn iter<'this>(&'this self) -> QueryComponentIter<'world, Comps>
     where
         'this: 'world,
@@ -274,6 +286,7 @@ where
     }
 
     /// Returns a weak reference query to the same components.
+    #[must_use]
     pub fn to_weak_ref(&self) -> WeakRefQuery<Comps>
     {
         WeakRefQuery {
@@ -367,6 +380,7 @@ where
     /// Returns a struct which can be used to retrieve a [`Query`].
     ///
     /// Returns [`None`] if the [`World`] has been dropped.
+    #[must_use]
     pub fn access(&self) -> Option<RefQuery<'_, Comps>>
     {
         Some(RefQuery {
@@ -404,6 +418,7 @@ impl<'weak_ref, Comps> RefQuery<'weak_ref, Comps>
 where
     Comps: ComponentSequence,
 {
+    #[must_use]
     pub fn to_query(&self) -> Query<'_, Comps>
     {
         Query::new(&self.component_storage)
diff --git a/ecs/src/lock.rs b/ecs/src/lock.rs
index ff46761..c8a8495 100644
--- a/ecs/src/lock.rs
+++ b/ecs/src/lock.rs
@@ -20,6 +20,10 @@ where
         Self { inner: RwLock::new(value) }
     }
 
+    /// Tries to a acquire a handle to the resource with read access.
+    ///
+    /// # Errors
+    /// Returns `Err` if unavailable (A mutable handle is hold).
     pub fn read_nonblock(&self) -> Result<ReadGuard<Value>, Error>
     {
         let guard = self.inner.try_read().or_else(|err| match err {
@@ -33,6 +37,10 @@ where
         Ok(ReadGuard { inner: guard })
     }
 
+    /// Tries to a acquire a handle to the resource with mutable access.
+    ///
+    /// # Errors
+    /// Returns `Err` if unavailable (A mutable or immutable handle is hold).
     pub fn write_nonblock(&self) -> Result<WriteGuard<Value>, Error>
     {
         let guard = self.inner.try_write().or_else(|err| match err {
-- 
cgit v1.2.3-18-g5258