#[non_exhaustive]pub struct Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>where
Registry: Registry,{
pub iter: Iterator,
pub resources: ResourceViews,
pub entries: Entries<'a, Registry, Resources, EntryViews, EntryIndices>,
}Expand description
The result of a query.
This struct contains both the iterator over the viewed entities, as well as the viewed resources.
§Example
The example below iterates over the entities returned by a query and counts them using a shared counter resource.
use brood::{World, Registry, resources, Query, entities, query::{Views, filter, result}};
// Components
#[derive(Clone)]
struct A(u32);
#[derive(Clone)]
struct B(char);
// Resource
#[derive(Debug, PartialEq)]
struct Count(u32);
let mut world = World::<Registry!(A, B), _>::with_resources(resources!(Count(0)));
world.extend(entities!((A(42), B('a')); 100));
let query_result = world.query(Query::<Views!(&A, &B), filter::None, Views!(&mut Count)>::new());
let result!(count) = query_result.resources;
for result!(_a, _b) in query_result.iter {
count.0 += 1;
}
assert_eq!(world.get::<Count, _>(), &Count(100));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.iter: IteratorThe viewed entities.
resources: ResourceViewsThe viewed resources.
entries: Entries<'a, Registry, Resources, EntryViews, EntryIndices>Entry access for the components specified by EntryViews.
This allows entity Entry lookup while iterating over the entities viewed by this query.
Auto Trait Implementations§
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Freeze for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> RefUnwindSafe for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>where
Iterator: RefUnwindSafe,
ResourceViews: RefUnwindSafe,
EntryViews: RefUnwindSafe,
EntryIndices: RefUnwindSafe,
Resources: RefUnwindSafe,
Registry: RefUnwindSafe,
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Send for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Sync for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Unpin for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> UnsafeUnpin for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>where
Iterator: UnsafeUnpin,
ResourceViews: UnsafeUnpin,
impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> UnwindSafe for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>where
Iterator: UnwindSafe,
ResourceViews: UnwindSafe,
EntryViews: UnwindSafe,
EntryIndices: UnwindSafe,
Resources: RefUnwindSafe,
Registry: RefUnwindSafe,
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> 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