Skip to content

Commit

Permalink
#[derive(Clone)] on Component{Info,Descriptor} (#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 Sep 20, 2023
1 parent 3ee9edf commit e07c427
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
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 e07c427

Please sign in to comment.