pub struct QueryBorrow<'w, Q>where
Q: Query,{ /* private fields */ }
Expand description
A borrow of a World
sufficient to execute the query Q
Note that borrows are not released until this object is dropped.
Implementations§
Source§impl<'w, Q> QueryBorrow<'w, Q>where
Q: Query,
impl<'w, Q> QueryBorrow<'w, Q>where
Q: Query,
Sourcepub fn iter_batched(&mut self, batch_size: u32) -> BatchedIter<'_, Q> ⓘ
pub fn iter_batched(&mut self, batch_size: u32) -> BatchedIter<'_, Q> ⓘ
Like iter
, but returns child iterators of at most batch_size
elements
Useful for distributing work over a threadpool.
Sourcepub fn with<R>(self) -> QueryBorrow<'w, With<Q, R>>where
R: Query,
pub fn with<R>(self) -> QueryBorrow<'w, With<Q, R>>where
R: Query,
Transform the query into one that requires another query be satisfied
Convenient when the values of the components in the other query are not of interest.
Equivalent to using a query type wrapped in With
.
§Example
let mut world = World::new();
let a = world.spawn((123, true, "abc"));
let b = world.spawn((456, false));
let c = world.spawn((42, "def"));
let entities = world.query::<&i32>()
.with::<&bool>()
.iter()
.map(|(e, &i)| (e, i)) // Copy out of the world
.collect::<Vec<_>>();
assert_eq!(entities.len(), 2);
assert!(entities.contains(&(a, 123)));
assert!(entities.contains(&(b, 456)));
Sourcepub fn without<R>(self) -> QueryBorrow<'w, Without<Q, R>>where
R: Query,
pub fn without<R>(self) -> QueryBorrow<'w, Without<Q, R>>where
R: Query,
Transform the query into one that skips entities satisfying another
Equivalent to using a query type wrapped in Without
.
§Example
let mut world = World::new();
let a = world.spawn((123, true, "abc"));
let b = world.spawn((456, false));
let c = world.spawn((42, "def"));
let entities = world.query::<&i32>()
.without::<&bool>()
.iter()
.map(|(e, &i)| (e, i)) // Copy out of the world
.collect::<Vec<_>>();
assert_eq!(entities, &[(c, 42)]);
Trait Implementations§
Source§impl<'w, Q> Drop for QueryBorrow<'w, Q>where
Q: Query,
impl<'w, Q> Drop for QueryBorrow<'w, Q>where
Q: Query,
Source§impl<'q, 'w, Q> IntoIterator for &'q mut QueryBorrow<'w, Q>where
Q: Query,
impl<'q, 'w, Q> IntoIterator for &'q mut QueryBorrow<'w, Q>where
Q: Query,
Source§fn into_iter(self) -> <&'q mut QueryBorrow<'w, Q> as IntoIterator>::IntoIter
fn into_iter(self) -> <&'q mut QueryBorrow<'w, Q> as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
impl<'w, Q> Send for QueryBorrow<'w, Q>
impl<'w, Q> Sync for QueryBorrow<'w, Q>
Auto Trait Implementations§
impl<'w, Q> Freeze for QueryBorrow<'w, Q>
impl<'w, Q> RefUnwindSafe for QueryBorrow<'w, Q>where
Q: RefUnwindSafe,
impl<'w, Q> Unpin for QueryBorrow<'w, Q>where
Q: Unpin,
impl<'w, Q> UnwindSafe for QueryBorrow<'w, Q>where
Q: UnwindSafe,
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