checs 0.5.1

An Entity-Component-System library.
Documentation
//! Checs is an Entity-Component-System library.
//!
//! ## Disclaimer
//!
//! This is a work in progress.

#![warn(missing_docs)]

pub mod component;
pub mod entity;
pub mod intersect;
pub mod iter;
pub mod query;
pub mod sparse;
pub mod world;

#[doc(inline)]
pub use crate::{
    component::ComponentVec,
    entity::Entity,
    intersect::Intersection,
    iter::{LendingIterator, Lifetime},
    query::{IntoQuery, Query},
    sparse::Set,
    world::{InsertMany, World},
};

/// Commonly used traits.
///
/// # Examples
///
/// ```
/// use checs::prelude::*;
/// ```
pub mod prelude {
    pub use crate::intersect::Intersect;
    pub use crate::iter::LendingIterator;
    pub use crate::query::IntoQuery;
    pub use crate::world::InsertMany;
}

/// Prepares a struct for use as the type parameter of a [`World`].
///
/// This custom derive implements [`RemoveAll`], as well as [`AsRef`] and [`AsMut`] for each field.
/// The struct's fields must by of type [`ComponentVec`].
///
/// # Note
///
/// If this custom derive cannot be used, e.g. because the feature `proc` is not enabled, the macro
/// [`derive_storage`] can be used instead.
///
/// [`World`]: world::World
/// [`ComponentVec`]: component::ComponentVec
/// [`RemoveAll`]: world::RemoveAll
/// [`derive_storage`]: crate::derive_storage
///
/// # Examples
///
/// ```
/// use checs::{ComponentVec, Storage};
///
/// #[derive(Default, Storage)]
/// struct Storage {
///     ints: ComponentVec<i32>,
///     floats: ComponentVec<f32>,
/// }
/// ```
///
/// The above will expand to something similar to this:
///
/// ```
/// # use checs::component::ComponentVec;
/// # use checs::Storage;
/// #
/// # #[derive(Default)]
/// # struct Storage {
/// #     ints: ComponentVec<i32>,
/// #     floats: ComponentVec<f32>,
/// # }
/// #
/// ::checs::internal_derive_storage!{
///     #[derive(Default)]
///     struct Storage {
///         ints: ComponentVec<i32>,
///         floats: ComponentVec<f32>,
///     }
/// }
/// ```
#[cfg(feature = "proc")]
pub use checs_proc::Storage;