Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - StorageType parameter removed from ComponentDescriptor::new_resource #3495

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,15 @@ impl ComponentDescriptor {
}
}

pub fn new_resource<T: Resource>(storage_type: StorageType) -> Self {
/// Create a new `ComponentDescriptor` for a resource.
///
/// The [`StorageType`] for resources is always [`TableStorage`].
pub fn new_resource<T: Resource>() -> Self {
Self {
name: std::any::type_name::<T>().to_string(),
storage_type,
// NOTE: `SparseStorage` may actually be a more
r4gus marked this conversation as resolved.
Show resolved Hide resolved
// reasonable choice as `storage_type` for resources.
storage_type: StorageType::Table,
is_send_and_sync: true,
type_id: Some(TypeId::of::<T>()),
layout: Layout::new::<T>(),
Expand Down Expand Up @@ -308,7 +313,7 @@ impl Components {
// SAFE: The [`ComponentDescriptor`] matches the [`TypeId`]
unsafe {
self.get_or_insert_resource_with(TypeId::of::<T>(), || {
ComponentDescriptor::new_resource::<T>(StorageType::default())
ComponentDescriptor::new_resource::<T>()
})
}
}
Expand Down