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

Create a new change set

Add a value to the change set. If the entity already have a value in the change set, the incoming value will be added to that.

Clear the changeset

Trait Implementations

Returns the “default value” for a type. Read more

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Creates a value from an iterator. Read more

Type of joined bit mask.

Type of joined components.

Type of joined storages.

Open this join by returning the mask and the storages. Read more

Get a joined component value by a given index. Read more

Create a joined iterator over the contents.

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more

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

Type of joined bit mask.

Type of joined components.

Type of joined storages.

Open this join by returning the mask and the storages. Read more

Get a joined component value by a given index. Read more

Create a joined iterator over the contents.

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more

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

A Join implementation for ChangeSet that simply removes all the entries on a call to get.

Type of joined bit mask.

Type of joined components.

Type of joined storages.

Open this join by returning the mask and the storages. Read more

Get a joined component value by a given index. Read more

Create a joined iterator over the contents.

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

Tries to create the default.

Calls try_default and panics on an error case.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.