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
					
				| @ -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
 |     /// You can override the provided implementation if you can return a `Command` with a smaller memory
 | ||||||
|     /// footprint than `(Entity, Self)`.
 |     /// footprint than `(Entity, Self)`.
 | ||||||
|     /// In most cases the provided implementation is sufficient.
 |     /// 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 |     fn with_entity(self, entity: Entity) -> impl Command | ||||||
|     where |     where | ||||||
|         Self: Sized, |         Self: Sized, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Joseph
						Joseph