[ecs] add StorageType documentation (#2394)

# Objective

- Add inline documentation for `StorageType`.
- Currently the README in `bevy_ecs` provides docs for `StorageType`, however, adding addition inline docs makes it simpler for users who are actively reading the source code.

## Solution
- Add inline docs.
This commit is contained in:
Nathan Ward 2021-06-30 16:38:24 +00:00
parent 10f2dd3ec5
commit c8e2415eaf

View file

@ -26,9 +26,25 @@ use thiserror::Error;
pub trait Component: Send + Sync + 'static {} pub trait Component: Send + Sync + 'static {}
impl<T: Send + Sync + 'static> Component for T {} impl<T: Send + Sync + 'static> Component for T {}
/// The storage used for a specific component type.
///
/// # Examples
/// The [`StorageType`] for a component is normally configured via `World::register_component`.
///
/// ```
/// # use bevy_ecs::{prelude::*, component::*};
///
/// struct A;
///
/// let mut world = World::default();
/// world.register_component(ComponentDescriptor::new::<A>(StorageType::SparseSet));
/// ```
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum StorageType { pub enum StorageType {
/// Provides fast and cache-friendly iteration, but slower addition and removal of components.
/// This is the default storage type.
Table, Table,
/// Provides fast addition and removal of components, but slower iteration.
SparseSet, SparseSet,
} }