#[derive(Clone)] on Component{Info,Descriptor} (#9812)

# 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`
This commit is contained in:
Sludge 2023-09-20 21:35:53 +02:00 committed by GitHub
parent 3ee9edf280
commit e07c427dea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,
@ -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