mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Emit a warning if the result of EntityCommand::with_entity
is not used (#14028)
When using combinators such as `EntityCommand::with_entity` to build commands, it can be easy to forget to apply that command, leading to dead code. In many cases this doesn't even lead to an unused variable warning, which can make these mistakes difficult to track down Annotate the method with `#[must_use]` Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
e65e4be98c
commit
a6feb5ba74
1 changed files with 1 additions and 0 deletions
|
@ -827,6 +827,7 @@ pub trait EntityCommand<Marker = ()>: Send + 'static {
|
|||
/// Executes this command for the given [`Entity`].
|
||||
fn apply(self, id: Entity, world: &mut World);
|
||||
/// Returns a [`Command`] which executes this [`EntityCommand`] for the given [`Entity`].
|
||||
#[must_use = "commands do nothing unless applied to a `World`"]
|
||||
fn with_entity(self, id: Entity) -> WithEntity<Marker, Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
Loading…
Reference in a new issue