Skip to content

Commit

Permalink
#[derive(Clone)] on Component{Info,Descriptor} (bevyengine#9812)
Browse files Browse the repository at this point in the history
# Objective

Occasionally, it is useful to pull `ComponentInfo` or
`ComponentDescriptor` out of the `Components` collection so that they
can be inspected without borrowing the whole `World`.

## Solution

Make `ComponentInfo` and `ComponentDescriptor` `Clone`, so that
reflection-heavy code can store them in a side table.

---

## Changelog

- Implement `Clone` for `ComponentInfo` and `ComponentDescriptor`
  • Loading branch information
SludgePhD authored and Ray Redondo committed Jan 9, 2024
1 parent 6506b09 commit 362d6ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/component.rs
Expand Up @@ -202,7 +202,7 @@ pub enum StorageType {
}

/// Stores metadata for a type of component or resource stored in a specific [`World`].
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct ComponentInfo {
id: ComponentId,
descriptor: ComponentDescriptor,
Expand Down Expand Up @@ -319,6 +319,7 @@ impl SparseSetIndex for ComponentId {
}

/// A value describing a component or resource, which may or may not correspond to a Rust type.
#[derive(Clone)]
pub struct ComponentDescriptor {
name: Cow<'static, str>,
// SAFETY: This must remain private. It must match the statically known StorageType of the
Expand Down

0 comments on commit 362d6ad

Please sign in to comment.