pub unsafe fn claim<T: Component>(&mut self) -> Option<&'a mut T::Storage> {
        let type_id = ComponentTypeId::of::<T>();
        #[cfg(debug_assertions)]
        {
            assert!(!self.claimed.contains(&type_id));
            self.claimed.insert(type_id);
        }
        // Self::extend_lifetime extends the local borrow up to 'a.
        // This is highly unsafe as it would allow aliasing a mutable borrow
        // by calling claim() multiple times for the same component.
        // However, the caller is responsible for not doing this as part of claim's safety rules.
        // We validate this in debug builds.
        self.components
            .storages
            .get_mut(&type_id)
            .and_then(|cell| Self::extend_lifetime(cell).downcast_mut())
    }
/// Claims exclusive access to a component storage.
///
/// # Safety
/// The caller must ensure that each component type is only claimed once, as doing otherwise
/// may result in mutable aliases of the component storage. This is validated in debug builds.
Claims exclusive access to a component storage.
Claims exclusive access to a component storage .
pub unsafe fn claim<T: Component>(&mut self) -> Option<&'a mut T::Storage> {
        let type_id = ComponentTypeId::of::<T>();
        #[cfg(debug_assertions)]
        {
            assert!(!self.claimed.contains(&type_id));
            self.claimed.insert(type_id);
        }
        // Self::extend_lifetime extends the local borrow up to 'a.
        // This is highly unsafe as it would allow aliasing a mutable borrow
        // by calling claim() multiple times for the same component.
        // However, the caller is responsible for not doing this as part of claim's safety rules.
        // We validate this in debug builds.
        self.components
            .storages
            .get_mut(&type_id)
            .and_then(|cell| Self::extend_lifetime(cell).downcast_mut())
    }
pub unsafe fn claim < T : Component > ( & mut self ) -> Option < & ' a mut T :: Storage > { let type_id = ComponentTypeId :: of :: < T > ( ) ; # [ cfg ( debug_assertions ) ] { assert ! ( self claimed contains ( type_id ) ) ; self . claimed . insert ( type_id ) ; } // Self::extend_lifetime extends the local borrow up to 'a. // This is highly unsafe as it would allow aliasing a mutable borrow // by calling claim() multiple times for the same component. // However, the caller is responsible for not doing this as part of claim's safety rules. // We validate this in debug builds. self . components . storages . get_mut ( & type_id ) . and_then ( | cell | Self :: extend_lifetime ( cell ) . downcast_mut ( ) ) }
Claims exclusive access to a component storage.
Claims exclusive access to a component storage .
&mut self
&mut self
safety
The caller must ensure that each component type is only claimed once, as doing otherwise
may result in mutable aliases of the component storage. This is validated in debug builds.
The caller must ensure that each component type is only claimed once as doing otherwise may result in mutable aliases of the component storage . This is validated in debug builds .