From 33cc01562c4aef94e605c9dc675450031a840d72 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 11 Dec 2024 13:52:34 +0100 Subject: refactor(ecs): make system::Param trait not unsafe --- ecs/src/actions.rs | 2 +- ecs/src/component/local.rs | 2 +- ecs/src/query.rs | 3 +-- ecs/src/sole.rs | 2 +- ecs/src/system.rs | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) (limited to 'ecs/src') diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs index 0878067..1ed49a8 100644 --- a/ecs/src/actions.rs +++ b/ecs/src/actions.rs @@ -92,7 +92,7 @@ impl<'world> Actions<'world> } } -unsafe impl<'world> SystemParam<'world> for Actions<'world> +impl<'world> SystemParam<'world> for Actions<'world> { type Flags = NoInitParamFlag; type Input = (); diff --git a/ecs/src/component/local.rs b/ecs/src/component/local.rs index 20627bf..aac4255 100644 --- a/ecs/src/component/local.rs +++ b/ecs/src/component/local.rs @@ -11,7 +11,7 @@ pub struct Local<'world, LocalComponent: Component> local_component: ComponentRefMut<'world, LocalComponent>, } -unsafe impl<'world, LocalComponent> SystemParam<'world> for Local<'world, LocalComponent> +impl<'world, LocalComponent> SystemParam<'world> for Local<'world, LocalComponent> where LocalComponent: Component, { diff --git a/ecs/src/query.rs b/ecs/src/query.rs index f3318bd..0a9eca1 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -156,8 +156,7 @@ where } } -unsafe impl<'world, Comps, OptionsT> SystemParam<'world> - for Query<'world, Comps, OptionsT> +impl<'world, Comps, OptionsT> SystemParam<'world> for Query<'world, Comps, OptionsT> where Comps: ComponentSequence, OptionsT: Options, diff --git a/ecs/src/sole.rs b/ecs/src/sole.rs index 084a06b..b7c9a68 100644 --- a/ecs/src/sole.rs +++ b/ecs/src/sole.rs @@ -88,7 +88,7 @@ where } } -unsafe impl<'world, SoleT> SystemParam<'world> for Single<'world, SoleT> +impl<'world, SoleT> SystemParam<'world> for Single<'world, SoleT> where SoleT: Sole, { diff --git a/ecs/src/system.rs b/ecs/src/system.rs index e273428..f266095 100644 --- a/ecs/src/system.rs +++ b/ecs/src/system.rs @@ -153,7 +153,7 @@ impl Debug for TypeErased type TypeErasedRunFn = dyn Fn(&dyn Any, &World) + RefUnwindSafe + UnwindSafe; /// A parameter to a [`System`]. -pub unsafe trait Param<'world> +pub trait Param<'world> { type Input; type Flags; -- cgit v1.2.3-18-g5258