Closed andrewgazelka closed 6 months ago
I would prefer a Fetcher::get_unchecked
method instead. It can be defined the same as Fetcher::get
but without the Q: ReadOnlyQuery
bound.
#[inline]
pub unsafe fn get_unchecked(&self, entity: EntityId) -> Result<Q::Item<'_>, GetError> {
self.state.get_unchecked(self.world.entities(), entity)
}
See also: https://docs.rs/bevy_ecs/latest/bevy_ecs/system/struct.Query.html#method.get_unchecked
I agree I like get unchecked better just wasn’t sure how to implement
This currently requires nightly. Maybe we could make our own
SyncUnsafeCell
?anyway, this type of thing can be useful for when I want to use
Fetcher
inside of aParallelIterator
and I know I have enforced invariants such that I will never be mutably accessing the same element from two places at once.This is the big use case I can think of and
UnsafeCell
will probs not be happy since it is notSync
butSyncUnsafeCell
would be.