pub unsafe fn claim_unknown(
        &mut self,
        type_id: ComponentTypeId,
    ) -> Option<&'a mut dyn UnknownComponentStorage> {
        #[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_unknown() multiple times for the same component.
        // However, the caller is responsible for not doing this as part of claim_unknown's safety
        // rules. We validate this in debug builds.
        self.components
            .storages
            .get_mut(&type_id)
            .map(|cell| Self::extend_lifetime(cell).deref_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_unknown(
        &mut self,
        type_id: ComponentTypeId,
    ) -> Option<&'a mut dyn UnknownComponentStorage> {
        #[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_unknown() multiple times for the same component.
        // However, the caller is responsible for not doing this as part of claim_unknown's safety
        // rules. We validate this in debug builds.
        self.components
            .storages
            .get_mut(&type_id)
            .map(|cell| Self::extend_lifetime(cell).deref_mut())
    }
pub unsafe fn claim_unknown ( & mut self , type_id : ComponentTypeId , ) -> Option < & ' a mut dyn UnknownComponentStorage > { # [ 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_unknown() multiple times for the same component. // However, the caller is responsible for not doing this as part of claim_unknown's safety // rules. We validate this in debug builds. self . components . storages . get_mut ( & type_id ) . map ( | cell | Self :: extend_lifetime ( cell ) . deref_mut ( ) ) }
Claims exclusive access to a component storage.
Claims exclusive access to a component storage .
&mut self
type_id
ComponentTypeId
&mut self
type_id
ComponentTypeId
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 .