pub struct QueryBorrow<'w, Q, F = All>{ /* private fields */ }Expand description
A lazily prepared query which borrows and hands out chunk iterators for each archetype matched.
The borrowing is lazy, as such, calling QueryBorrow::get will only borrow the one required archetype.
QueryBorrow::iter will borrow the components from all archetypes and release them once the prepared query drops.
Subsequent calls to iter will use the same borrow.
Implementations§
Source§impl<'w, Q, F> QueryBorrow<'w, Q, F>
impl<'w, Q, F> QueryBorrow<'w, Q, F>
Sourcepub fn iter<'q>(&'q mut self) -> QueryIter<'w, 'q, Q, F> ⓘwhere
'w: 'q,
pub fn iter<'q>(&'q mut self) -> QueryIter<'w, 'q, Q, F> ⓘwhere
'w: 'q,
Iterate all items matched by query and filter.
Sourcepub fn iter_batched<'q>(&'q mut self) -> BatchedIter<'w, 'q, Q, F> ⓘwhere
'w: 'q,
pub fn iter_batched<'q>(&'q mut self) -> BatchedIter<'w, 'q, Q, F> ⓘwhere
'w: 'q,
Iterate all items matched by query and filter.
Sourcepub fn for_each(
&mut self,
func: impl FnMut(<Q as FetchItem<'_>>::Item) + Send + Sync,
)
pub fn for_each( &mut self, func: impl FnMut(<Q as FetchItem<'_>>::Item) + Send + Sync, )
Execute a closure for each item in the iterator.
This is more efficient than .iter().for_each(|v| {}) as the archetypes can be temporarily
borrowed.
Sourcepub fn par_for_each(
&mut self,
func: impl Fn(<Q as FetchItem<'_>>::Item) + Send + Sync,
)
Available on crate feature rayon only.
pub fn par_for_each( &mut self, func: impl Fn(<Q as FetchItem<'_>>::Item) + Send + Sync, )
rayon only.Shorthand for:
ⓘ
self.iter_batched()
.par_bridge()
.for_each(|v| v.for_each(&func))Sourcepub fn clear_borrows(&mut self)
pub fn clear_borrows(&mut self)
Release all borrowed archetypes
Trait Implementations§
Source§impl<'w, 'q, Q, F> IntoIterator for &'q mut QueryBorrow<'w, Q, F>
impl<'w, 'q, Q, F> IntoIterator for &'q mut QueryBorrow<'w, Q, F>
Auto Trait Implementations§
impl<'w, Q, F> Freeze for QueryBorrow<'w, Q, F>
impl<'w, Q, F = All> !RefUnwindSafe for QueryBorrow<'w, Q, F>
impl<'w, Q, F> Send for QueryBorrow<'w, Q, F>
impl<'w, Q, F> Sync for QueryBorrow<'w, Q, F>
impl<'w, Q, F> Unpin for QueryBorrow<'w, Q, F>
impl<'w, Q, F = All> !UnwindSafe for QueryBorrow<'w, Q, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more