Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make standard commands more ergonomic (in niche cases) (#8249)
# Objective I ran into a case where I need to create a `CommandQueue` and push standard `Command` actions like `Insert` or `Remove` to it manually. I saw that `Remove` looked as follows: ```rust struct Remove<T> { entity: Entity, phantom: PhantomData<T> } ``` so naturally, I tried to use `Remove::<Foo>::from(entity)` but it didn't exist. We need to specify the `PhantomData` explicitly when creating this command action. The same goes for `RemoveResource` and `InitResource` ## Solution This PR implements the following: - `From<Entity>` for `Remove<T>` - `Default` for `RemoveResource` and `InitResource` - use these traits in the implementation of methods of `Commands` - rename `phantom` field on the structs above to `_phantom` to have a more uniform field naming scheme for the command actions --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. - Added: implemented `From<Entity>` for `Remove<T>` and `Default` for `RemoveResource` and `InitResource` for ergonomics --------- Co-authored-by: Alice Cecile <[email protected]>
- Loading branch information