[−][src]Struct hecs::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: Query> QueryBorrow<'w, Q>
[src]
pub fn iter(&mut self) -> QueryIter<'_, Q>ⓘ
[src]
Execute the query
Must be called only once per query.
pub fn iter_batched(&mut self, batch_size: u32) -> BatchedIter<'_, Q>ⓘNotable traits for BatchedIter<'q, Q>
impl<'q, Q: Query> Iterator for BatchedIter<'q, Q> type Item = Batch<'q, Q>;
[src]
Notable traits for BatchedIter<'q, Q>
impl<'q, Q: Query> Iterator for BatchedIter<'q, Q> 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: Component>(self) -> QueryBorrow<'w, With<T, Q>>
[src]
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::<&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: Component>(self) -> QueryBorrow<'w, Without<T, Q>>
[src]
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::<&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: Query> Drop for QueryBorrow<'w, Q>
[src]
impl<'q, 'w, Q: Query> IntoIterator for &'q mut QueryBorrow<'w, Q>
[src]
type Item = (Entity, QueryItem<'q, Q>)
The type of the elements being iterated over.
type IntoIter = QueryIter<'q, Q>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'w, Q: Query> Send for QueryBorrow<'w, Q>
[src]
impl<'w, Q: Query> Sync for QueryBorrow<'w, Q>
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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.
pub 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>,