Skip to content

Commit e79f91f

Browse files
Rename bevy_core::name::DebugName to bevy_core::name::NameOrEntity (#14211)
# Objective - Fixes #14039 ## Solution - Rename. ## Testing - CI --- ## Migration Guide - Rename usages of `bevy_core::name::DebugName` to `bevy_core::name::NameOrEntity`
1 parent bc72ced commit e79f91f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

crates/bevy_core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub mod prelude {
2020
//! The Bevy Core Prelude.
2121
#[doc(hidden)]
2222
pub use crate::{
23-
DebugName, FrameCountPlugin, Name, TaskPoolOptions, TaskPoolPlugin, TypeRegistrationPlugin,
23+
FrameCountPlugin, Name, NameOrEntity, TaskPoolOptions, TaskPoolPlugin,
24+
TypeRegistrationPlugin,
2425
};
2526
}
2627

crates/bevy_core/src/name.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl std::fmt::Debug for Name {
107107
/// # use bevy_core::prelude::*;
108108
/// # use bevy_ecs::prelude::*;
109109
/// # #[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)>) {
111111
/// for (name, mut score) in &mut scores {
112112
/// score.0 += 1.0;
113113
/// if score.0.is_nan() {
@@ -120,18 +120,18 @@ impl std::fmt::Debug for Name {
120120
///
121121
/// # Implementation
122122
///
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
124124
/// or {index}v{generation} for entities without one.
125125
#[derive(QueryData)]
126126
#[query_data(derive(Debug))]
127-
pub struct DebugName {
127+
pub struct NameOrEntity {
128128
/// A [`Name`] that the entity might have that is displayed if available.
129129
pub name: Option<&'static Name>,
130130
/// The unique identifier of the entity as a fallback.
131131
pub entity: Entity,
132132
}
133133

134-
impl<'a> std::fmt::Display for DebugNameItem<'a> {
134+
impl<'a> std::fmt::Display for NameOrEntityItem<'a> {
135135
#[inline(always)]
136136
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
137137
match self.name {
@@ -227,12 +227,12 @@ mod tests {
227227
let e1 = world.spawn_empty().id();
228228
let name = Name::new("MyName");
229229
let e2 = world.spawn(name.clone()).id();
230-
let mut query = world.query::<DebugName>();
230+
let mut query = world.query::<NameOrEntity>();
231231
let d1 = query.get(&world, e1).unwrap();
232232
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}
234234
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
236236
assert_eq!(d2.to_string(), "MyName");
237237
}
238238
}

0 commit comments

Comments
 (0)