From 4f265b19efbbf93301dc40e025466c97678adb41 Mon Sep 17 00:00:00 2001 From: "Richard Dodd (dodj)" Date: Tue, 23 Apr 2024 16:55:59 +0100 Subject: [PATCH] Implement GenericReadStorage for mutable reference Without this it's not possible to pass `&mut WriteStorage<_>` as a `GenericReadStorage`. --- src/storage/generic.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/storage/generic.rs b/src/storage/generic.rs index 84f81a196..1607dd814 100644 --- a/src/storage/generic.rs +++ b/src/storage/generic.rs @@ -78,6 +78,22 @@ where } } + +impl<'a: 'b, 'b, T> GenericReadStorage for &'b mut WriteStorage<'a, T> +where + T: Component, +{ + type Component = T; + + fn get(&self, entity: Entity) -> Option<&Self::Component> { + WriteStorage::get(*self, entity) + } + + fn _private() -> Seal { + Seal + } +} + /// Provides generic write access to `WriteStorage`, both as a value and a /// mutable reference. pub trait GenericWriteStorage {