mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
Emit a warning if the result of EntityCommand::with_entity
is not used (#14028)
# Objective 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 ## Solution Annotate the method with `#[must_use]` Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
ee63cf45c6
commit
2b7d54b300
1 changed files with 1 additions and 0 deletions
|
@ -832,6 +832,7 @@ pub trait EntityCommand<Marker = ()>: Send + 'static {
|
|||
/// You can override the provided implementation if you can return a `Command` with a smaller memory
|
||||
/// footprint than `(Entity, Self)`.
|
||||
/// In most cases the provided implementation is sufficient.
|
||||
#[must_use = "commands do nothing unless applied to a `World`"]
|
||||
fn with_entity(self, entity: Entity) -> impl Command
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
Loading…
Add table
Reference in a new issue