rs_ecs/
lib.rs

1//! A reasonably simple entity component system (ECS).
2//!
3//! The design is based on [hecs](https://github.com/Ralith/hecs) but it is not thread-safe
4//! and has a significantly reduced API surface.
5//!
6//! # Example
7//!
8//! ```
9//! # use rs_ecs::*;
10//!
11//! let mut world = World::new();
12//!
13//! let entity = world.alloc();
14//! world.insert(entity, (42_u32, true));
15//!
16//! let entity = world.alloc();
17//! world.insert(entity, (23_u32, "hello".to_string()));
18//!
19//! for number in Query::<&u32>::new().borrow(&world).iter() {
20//!     println!("{}", number);
21//! }
22//!
23//! for (_entity, number, string) in Query::<(&Entity, &u32, &String)>::new().borrow(&world).iter() {
24//!     println!("{}, {}", string, number);
25//! }
26//! ```
27
28#![warn(missing_docs)]
29
30mod archetype;
31mod borrow_flags;
32mod query;
33mod resources;
34mod world;
35
36pub use crate::{
37    archetype::Cloner,
38    query::{Matches, Query, QueryIter, QueryMap, QueryRef, QuerySpec, With, Without},
39    resources::{Res, ResMut, Resources},
40    world::{Entity, QueryOne, World},
41};
42
43#[cfg(feature = "rayon")]
44mod rayon;
45
46#[cfg(feature = "rayon")]
47pub use crate::rayon::QueryParIter;