pub struct ViewBorrow<'w, Q>where
Q: Query,{ /* private fields */ }Expand description
Implementations§
Source§impl<'w, Q> ViewBorrow<'w, Q>where
Q: Query,
impl<'w, Q> ViewBorrow<'w, Q>where
Q: Query,
Sourcepub fn get(&self, entity: Entity) -> Option<<Q as Query>::Item<'_>>where
Q: QueryShared,
pub fn get(&self, entity: Entity) -> Option<<Q as Query>::Item<'_>>where
Q: QueryShared,
Retrieve the query results corresponding to entity
Will yield None if the entity does not exist or does not match the query.
Does not require exclusive access to the map, but is defined only for queries yielding only shared references.
See `View::get``.
Sourcepub fn get_mut(&mut self, entity: Entity) -> Option<<Q as Query>::Item<'_>>
pub fn get_mut(&mut self, entity: Entity) -> Option<<Q as Query>::Item<'_>>
Retrieve the query results corresponding to entity
Will yield None if the entity does not exist or does not match the query.
See `View::get_mut``.
Sourcepub fn contains(&self, entity: Entity) -> bool
pub fn contains(&self, entity: Entity) -> bool
Equivalent to get(entity).is_some(), but does not require Q: QueryShared
See `View::contains``.
Sourcepub unsafe fn get_unchecked(
&self,
entity: Entity,
) -> Option<<Q as Query>::Item<'_>>
pub unsafe fn get_unchecked( &self, entity: Entity, ) -> Option<<Q as Query>::Item<'_>>
Like get_mut, but allows simultaneous access to multiple entities
§Safety
Must not be invoked while any unique borrow of the fetched components of entity is live.
Sourcepub fn get_many_mut<const N: usize>(
&mut self,
entities: [Entity; N],
) -> [Option<<Q as Query>::Item<'_>>; N]
pub fn get_many_mut<const N: usize>( &mut self, entities: [Entity; N], ) -> [Option<<Q as Query>::Item<'_>>; N]
Like get_mut, but allows checked simultaneous access to multiple entities
For N > 3, the check for distinct entities will clone the array and take O(N log N) time.
§Examples
let mut world = World::new();
let a = world.spawn((1, 1.0));
let b = world.spawn((2, 4.0));
let c = world.spawn((3, 9.0));
let mut view = world.view_mut::<&mut i32>();
let [a, b, c] = view.get_mut_n([a, b, c]);
assert_eq!(*a.unwrap(), 1);
assert_eq!(*b.unwrap(), 2);
assert_eq!(*c.unwrap(), 3);Trait Implementations§
Source§impl<'w, Q> Drop for ViewBorrow<'w, Q>where
Q: Query,
impl<'w, Q> Drop for ViewBorrow<'w, Q>where
Q: Query,
Source§impl<'a, 'q, Q> IntoIterator for &'a mut ViewBorrow<'q, Q>where
Q: Query,
impl<'a, 'q, Q> IntoIterator for &'a mut ViewBorrow<'q, Q>where
Q: Query,
Source§fn into_iter(self) -> <&'a mut ViewBorrow<'q, Q> as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a mut ViewBorrow<'q, Q> as IntoIterator>::IntoIter
Auto Trait Implementations§
impl<'w, Q> Freeze for ViewBorrow<'w, Q>
impl<'w, Q> RefUnwindSafe for ViewBorrow<'w, Q>
impl<'w, Q> Send for ViewBorrow<'w, Q>
impl<'w, Q> Sync for ViewBorrow<'w, Q>
impl<'w, Q> Unpin for ViewBorrow<'w, Q>
impl<'w, Q> UnwindSafe for ViewBorrow<'w, Q>
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
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> ⓘ
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> ⓘ
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