pub struct ChangeSet<T> { /* private fields */ }
Expand description
Change set that can be collected from an iterator, and joined on for easy application to components.
Example
pub struct Health(i32);
impl Component for Health {
type Storage = DenseVecStorage<Self>;
}
let a = world.create_entity().with(Health(100)).build();
let b = world.create_entity().with(Health(200)).build();
let changeset = [(a, 32), (b, 12), (b, 13)]
.iter()
.cloned()
.collect::<ChangeSet<i32>>();
for (health, modifier) in (&mut world.write_storage::<Health>(), &changeset).join() {
health.0 -= modifier;
}
Implementations
Trait Implementations
sourceimpl<T> Extend<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
impl<T> Extend<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
sourcefn extend<I: IntoIterator<Item = (Entity, T)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (Entity, T)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
impl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
sourcefn from_iter<I: IntoIterator<Item = (Entity, T)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (Entity, T)>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<'a, T> Join for &'a ChangeSet<T>
impl<'a, T> Join for &'a ChangeSet<T>
type Value = &'a DenseVecStorage<T>
type Value = &'a DenseVecStorage<T>
Type of joined storages.
sourceunsafe fn open(self) -> (Self::Mask, Self::Value)
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
sourceunsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index. Read more
sourcefn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
fn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
Create a joined iterator over the contents.
sourcefn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
Returns a Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read more
sourcefn is_unconstrained() -> bool
fn is_unconstrained() -> bool
If this Join
typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter
/ParJoin
to go through all indices which
is usually not what is wanted and will kill performance. Read more
sourceimpl<'a, T> Join for &'a mut ChangeSet<T>
impl<'a, T> Join for &'a mut ChangeSet<T>
type Value = &'a mut DenseVecStorage<T>
type Value = &'a mut DenseVecStorage<T>
Type of joined storages.
sourceunsafe fn open(self) -> (Self::Mask, Self::Value)
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
sourceunsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type
unsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index. Read more
sourcefn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
fn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
Create a joined iterator over the contents.
sourcefn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
Returns a Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read more
sourcefn is_unconstrained() -> bool
fn is_unconstrained() -> bool
If this Join
typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter
/ParJoin
to go through all indices which
is usually not what is wanted and will kill performance. Read more
sourceimpl<T> Join for ChangeSet<T>
impl<T> Join for ChangeSet<T>
A Join
implementation for ChangeSet
that simply removes all the entries
on a call to get
.
type Type = T
type Type = T
Type of joined components.
type Value = DenseVecStorage<T>
type Value = DenseVecStorage<T>
Type of joined storages.
sourceunsafe fn open(self) -> (Self::Mask, Self::Value)
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
sourceunsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index. Read more
sourcefn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
fn join(self) -> JoinIter<Self>ⓘNotable traits for JoinIter<J>impl<J: Join> Iterator for JoinIter<J> type Item = J::Type;
where
Self: Sized,
Create a joined iterator over the contents.
sourcefn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
Returns a Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read more
sourcefn is_unconstrained() -> bool
fn is_unconstrained() -> bool
If this Join
typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter
/ParJoin
to go through all indices which
is usually not what is wanted and will kill performance. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for ChangeSet<T> where
T: RefUnwindSafe,
impl<T> Send for ChangeSet<T> where
T: Send,
impl<T> Sync for ChangeSet<T> where
T: Sync,
impl<T> Unpin for ChangeSet<T> where
T: Unpin,
impl<T> UnwindSafe for ChangeSet<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> TryDefault for T where
T: Default,
impl<T> TryDefault for T where
T: Default,
sourcefn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
sourcefn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls try_default
and panics on an error case.