From 93f9f840da11b82c8a13f31f0ba5db8b10e4e9ad Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 29 Jun 2024 18:41:04 +0200 Subject: refactor(ecs): pass World ref to system run & param new functions --- ecs/src/system/stateful.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ecs/src/system/stateful.rs') diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs index 56c9d4f..26ceaaa 100644 --- a/ecs/src/system/stateful.rs +++ b/ecs/src/system/stateful.rs @@ -21,7 +21,7 @@ use crate::tuple::{ TakeOptionElementResult as TupleTakeOptionElementResult, WithOptionElements as TupleWithOptionElements, }; -use crate::WorldData; +use crate::{World, WorldData}; /// A stateful system. pub struct Stateful @@ -92,7 +92,7 @@ macro_rules! impl_system { )* } - fn run<'this>(&'this self, world_data: &'world WorldData) + fn run<'this>(&'this self, world: &'world World) where 'this: 'world { @@ -103,7 +103,7 @@ macro_rules! impl_system { let func = self.func; func(#({ - TParam~I::new(self, world_data) + TParam~I::new(self, &world) },)*); } @@ -111,7 +111,7 @@ macro_rules! impl_system { { TypeErased { data: Box::new(self), - run: Box::new(|data, world_data| { + run: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref::(data) }; @@ -120,11 +120,11 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.run(world_data); + me.run(world); }), - prepare: Box::new(|data, world_data| { + prepare: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref::(data) }; @@ -133,9 +133,9 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.prepare(world_data); + me.prepare(world); }), } } -- cgit v1.2.3-18-g5258