Skip to content

Commit

Permalink
docs: document root module
Browse files Browse the repository at this point in the history
  • Loading branch information
LechintanTudor committed Aug 29, 2024
1 parent 7d3731a commit c2389e1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "sparsey"
version = "0.12.1"
edition = "2021"
description = "Sparse set-based entity component system"
description = "Entity Component System based on sparse sets"
authors = ["Tudor-Cristian Lechințan <[email protected]>"]
repository = "https://github.com/LechintanTudor/sparsey"
keywords = ["component", "ecs", "entity", "gamedev", "system"]
Expand All @@ -22,12 +22,9 @@ features = ["inline-more"]

[features]
default = ["std"]
std = []
std = ["rustc-hash/std"]
parallel = ["std", "dep:rayon"]

[lints.rust]
# missing-docs = "forbid"

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
cast-possible-truncation = "allow"
Expand Down
40 changes: 39 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
#![no_std]
//! Sparsey is an [Entity Component System (ECS)](https://www.geeksforgeeks.org/sparse-set/)
//! based on [sparse sets](https://www.geeksforgeeks.org/sparse-set/).
//!
//! # Example
//! ```rust
//! use sparsey::World;
//!
//! struct Position(i32, i32);
//! struct Velocity(i32, i32);
//!
//! fn main() {
//! let mut world = World::builder()
//! .register::<Position>()
//! .register::<Velocity>()
//! .build();
//!
//! world.create((Position(0, 0), Velocity(1, 2)));
//! world.create((Position(0, 0), Velocity(2, 3)));
//!
//! world.for_each::<(&mut Position, &Velocity)>(|(position, velocity)| {
//! position.0 += velocity.0;
//! position.1 += velocity.1;
//! });
//! }
//! ```
//!
//! # Features
//!
//! - `std` (on by default): link to the `std` crate.
//! - `parallel`: enable parallel iterators.
//!
//! # Usage
//!
//! The most important items from Sparsey crate are [`World`] and [`Entity`], which are re-exported
//! at the root of the crate for easy access. A [`World`] is a collection of entities and components
//! thas supports create/read/update/delete (CRUD) operations, while an [`Entity`] is a versioned
//! index used to reference components within a [`World`].

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

Expand Down

0 comments on commit c2389e1

Please sign in to comment.