@@ -107,7 +107,7 @@ impl std::fmt::Debug for Name {
107
107
/// # use bevy_core::prelude::*;
108
108
/// # use bevy_ecs::prelude::*;
109
109
/// # #[derive(Component)] pub struct Score(f32);
110
- /// fn increment_score(mut scores: Query<(DebugName , &mut Score)>) {
110
+ /// fn increment_score(mut scores: Query<(NameOrEntity , &mut Score)>) {
111
111
/// for (name, mut score) in &mut scores {
112
112
/// score.0 += 1.0;
113
113
/// if score.0.is_nan() {
@@ -120,18 +120,18 @@ impl std::fmt::Debug for Name {
120
120
///
121
121
/// # Implementation
122
122
///
123
- /// The `Display` impl for `DebugName ` returns the `Name` where there is one
123
+ /// The `Display` impl for `NameOrEntity ` returns the `Name` where there is one
124
124
/// or {index}v{generation} for entities without one.
125
125
#[ derive( QueryData ) ]
126
126
#[ query_data( derive( Debug ) ) ]
127
- pub struct DebugName {
127
+ pub struct NameOrEntity {
128
128
/// A [`Name`] that the entity might have that is displayed if available.
129
129
pub name : Option < & ' static Name > ,
130
130
/// The unique identifier of the entity as a fallback.
131
131
pub entity : Entity ,
132
132
}
133
133
134
- impl < ' a > std:: fmt:: Display for DebugNameItem < ' a > {
134
+ impl < ' a > std:: fmt:: Display for NameOrEntityItem < ' a > {
135
135
#[ inline( always) ]
136
136
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
137
137
match self . name {
@@ -227,12 +227,12 @@ mod tests {
227
227
let e1 = world. spawn_empty ( ) . id ( ) ;
228
228
let name = Name :: new ( "MyName" ) ;
229
229
let e2 = world. spawn ( name. clone ( ) ) . id ( ) ;
230
- let mut query = world. query :: < DebugName > ( ) ;
230
+ let mut query = world. query :: < NameOrEntity > ( ) ;
231
231
let d1 = query. get ( & world, e1) . unwrap ( ) ;
232
232
let d2 = query. get ( & world, e2) . unwrap ( ) ;
233
- // DebugName Display for entities without a Name should be {index}v{generation}
233
+ // NameOrEntity Display for entities without a Name should be {index}v{generation}
234
234
assert_eq ! ( d1. to_string( ) , "0v1" ) ;
235
- // DebugName Display for entities with a Name should be the Name
235
+ // NameOrEntity Display for entities with a Name should be the Name
236
236
assert_eq ! ( d2. to_string( ) , "MyName" ) ;
237
237
}
238
238
}
0 commit comments