bevy/crates
Eagster 202faf6a1c Get names of queued components (#18451)
# Objective

#18173 allows components to be queued without being fully registered.
But much of bevy's debug logging contained
`components.get_name(id).unwrap()`. However, this panics when the id is
queued. This PR fixes this, allowing names to be retrieved for debugging
purposes, etc, even while they're still queued.

## Solution

We change `ComponentInfo::descriptor` to be `Arc<ComponentDescriptor>`
instead of not arc'd. This lets us pass the descriptor around (as a name
or otherwise) as needed. The alternative would require some form of
`MappedRwLockReadGuard`, which is unstable, and would be terribly
blocking. Putting it in an arc also signifies that it doesn't change,
which is a nice signal to users. This does mean there's an extra pointer
dereference, but I don't think that's an issue here, as almost all paths
that use this are for debugging purposes or one-time set ups.

## Testing

Existing tests.

## Migration Guide

`Components::get_name` now returns `Option<Cow<'_, str>` instead of
`Option<&str>`. This is because it now returns results for queued
components. If that behavior is not desired, or you know the component
is not queued, you can use
`components.get_info().map(ComponentInfo::name)` instead.

Similarly, `ScheduleGraph::conflicts_to_string` now returns `impl
Iterator<Item = (String, String, Vec<Cow<str>>)>` instead of `impl
Iterator<Item = (String, String, Vec<&str>)>`. Because `Cow<str>` derefs
to `&str`, most use cases can remain unchanged.

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-04-03 21:45:42 +02:00
..
bevy_a11y Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_animation Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_app Add sleep based on spin to bevy_platform_support (#18633) 2025-04-03 21:45:42 +02:00
bevy_asset Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_audio Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_color Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_core_pipeline Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_derive Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_dev_tools Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_diagnostic Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_dylib Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_ecs Get names of queued components (#18451) 2025-04-03 21:45:42 +02:00
bevy_encase_derive Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_gilrs Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_gizmos Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_gltf Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_image Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_input Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_input_focus Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_internal Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_log Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_macro_utils Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_math Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_mesh Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_mikktspace Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_pbr Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_picking Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_platform_support Add sleep based on spin to bevy_platform_support (#18633) 2025-04-03 21:45:42 +02:00
bevy_ptr Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_reflect Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_remote Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_render Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_scene Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_sprite Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_state Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_tasks Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_text Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_time Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_transform Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_ui Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_utils Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_window Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00
bevy_winit Release 0.16.0-rc.3 2025-03-31 23:07:43 +02:00