checs/
lib.rs

1//! Checs is an Entity-Component-System library.
2//!
3//! ## Disclaimer
4//!
5//! This is a work in progress.
6
7#![warn(missing_docs)]
8
9pub mod component;
10pub mod entity;
11pub mod intersect;
12pub mod iter;
13pub mod query;
14pub mod sparse;
15pub mod world;
16
17#[doc(inline)]
18pub use crate::{
19    component::ComponentVec,
20    entity::Entity,
21    intersect::Intersection,
22    iter::{LendingIterator, Lifetime},
23    query::{IntoQuery, Query},
24    sparse::Set,
25    world::{InsertMany, World},
26};
27
28/// Commonly used traits.
29///
30/// # Examples
31///
32/// ```
33/// use checs::prelude::*;
34/// ```
35pub mod prelude {
36    pub use crate::intersect::Intersect;
37    pub use crate::iter::LendingIterator;
38    pub use crate::query::IntoQuery;
39    pub use crate::world::InsertMany;
40}
41
42/// Prepares a struct for use as the type parameter of a [`World`].
43///
44/// This custom derive implements [`RemoveAll`], as well as [`AsRef`] and [`AsMut`] for each field.
45/// The struct's fields must by of type [`ComponentVec`].
46///
47/// # Note
48///
49/// If this custom derive cannot be used, e.g. because the feature `proc` is not enabled, the macro
50/// [`derive_storage`] can be used instead.
51///
52/// [`World`]: world::World
53/// [`ComponentVec`]: component::ComponentVec
54/// [`RemoveAll`]: world::RemoveAll
55/// [`derive_storage`]: crate::derive_storage
56///
57/// # Examples
58///
59/// ```
60/// use checs::{ComponentVec, Storage};
61///
62/// #[derive(Default, Storage)]
63/// struct Storage {
64///     ints: ComponentVec<i32>,
65///     floats: ComponentVec<f32>,
66/// }
67/// ```
68///
69/// The above will expand to something similar to this:
70///
71/// ```
72/// # use checs::component::ComponentVec;
73/// # use checs::Storage;
74/// #
75/// # #[derive(Default)]
76/// # struct Storage {
77/// #     ints: ComponentVec<i32>,
78/// #     floats: ComponentVec<f32>,
79/// # }
80/// #
81/// ::checs::internal_derive_storage!{
82///     #[derive(Default)]
83///     struct Storage {
84///         ints: ComponentVec<i32>,
85///         floats: ComponentVec<f32>,
86///     }
87/// }
88/// ```
89#[cfg(feature = "proc")]
90pub use checs_proc::Storage;