[−][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.
Methods
impl<'w, Q: Query> QueryBorrow<'w, Q>
[src]
ⓘImportant traits for QueryIter<'q, 'w, Q>pub fn iter<'q>(&'q mut self) -> QueryIter<'q, 'w, Q>
[src]
ⓘImportant traits for QueryIter<'q, 'w, Q>
Execute the query
Must be called only once per query.
pub fn with<T: Component>(self) -> QueryBorrow<'w, With<Q, T>>
[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.
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<Q, T>>
[src]
Transform the query into one that skips entities having a certain component
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, <Q::Fetch as Fetch<'q>>::Item)
The type of the elements being iterated over.
type IntoIter = QueryIter<'q, 'w, 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,
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.
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>,