[−][src]Struct bevy_ecs::QueryBorrow
A borrow of a World
sufficient to execute the query Q
Note that borrows are not released until this object is dropped.
Implementations
impl<'w, Q> QueryBorrow<'w, Q> where
Q: Query,
[src]
Q: Query,
pub fn iter(&'q mut self) -> QueryIter<'q, 'w, Q>ⓘ
[src]
Execute the query
Must be called only once per query.
pub fn iter_batched(&'q mut self, batch_size: u32) -> BatchedIter<'q, 'w, Q>ⓘImportant traits for BatchedIter<'q, 'w, Q>
impl<'q, 'w, Q> Iterator for BatchedIter<'q, 'w, Q> where
Q: Query, type Item = Batch<'q, Q>;
[src]
Important traits for BatchedIter<'q, 'w, Q>
impl<'q, 'w, Q> Iterator for BatchedIter<'q, 'w, Q> where
Q: Query, type Item = Batch<'q, Q>;
Like iter
, but returns child iterators of at most batch_size
elements
Useful for distributing work over a threadpool.
pub fn with<T>(self) -> QueryBorrow<'w, With<T, Q>> where
T: Component,
[src]
T: Component,
Transform the query into one that requires a certain component without borrowing it
This can be useful when the component needs to be borrowed elsewhere and it isn't necessary for the iterator to expose its data directly.
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::<(Entity, &i32)>() .with::<bool>() .iter() .map(|(e, &i)| (e, i)) // Copy out of the world .collect::<Vec<_>>(); assert!(entities.contains(&(a, 123))); assert!(entities.contains(&(b, 456)));
pub fn without<T>(self) -> QueryBorrow<'w, Without<T, Q>> where
T: Component,
[src]
T: Component,
Transform the query into one that skips entities having a certain component
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::<(Entity, &i32)>() .without::<bool>() .iter() .map(|(e, &i)| (e, i)) // Copy out of the world .collect::<Vec<_>>(); assert_eq!(entities, &[(c, 42)]);
Trait Implementations
impl<'w, Q> Drop for QueryBorrow<'w, Q> where
Q: Query,
[src]
Q: Query,
impl<'q, 'w, Q> IntoIterator for &'q mut QueryBorrow<'w, Q> where
Q: Query,
[src]
Q: Query,
type IntoIter = QueryIter<'q, 'w, Q>
Which kind of iterator are we turning this into?
type Item = <<Q as Query>::Fetch as Fetch<'q>>::Item
The type of the elements being iterated over.
fn into_iter(self) -> <&'q mut QueryBorrow<'w, Q> as IntoIterator>::IntoIter
[src]
impl<'w, Q> Send for QueryBorrow<'w, Q> where
Q: Query,
[src]
Q: Query,
impl<'w, Q> Sync for QueryBorrow<'w, Q> where
Q: Query,
[src]
Q: Query,
Auto Trait Implementations
impl<'w, Q> !RefUnwindSafe for QueryBorrow<'w, Q>
impl<'w, Q> Unpin for QueryBorrow<'w, Q> where
Q: Unpin,
Q: Unpin,
impl<'w, Q> !UnwindSafe for QueryBorrow<'w, Q>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Component for T where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,