Skip to main content

Result

Struct Result 

Source
#[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: Iterator

The viewed entities.

§resources: ResourceViews

The 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>
where Iterator: Freeze, ResourceViews: Freeze,

§

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>
where Iterator: Send, ResourceViews: Send,

§

impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Sync for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
where Iterator: Sync, ResourceViews: Sync,

§

impl<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices> Unpin for Result<'a, Registry, Resources, Iterator, ResourceViews, EntryViews, EntryIndices>
where Iterator: Unpin, ResourceViews: Unpin, EntryViews: Unpin, EntryIndices: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<Component> Component for Component
where Component: Any,

Source§

impl<'a, Views, Filter, Index> ContainsFilter<'a, Filter, Index> for Views
where Views: Sealed<'a, Filter, Index>,

Source§

impl<T> Resource for T
where T: Any,