Struct rs_ecs::World [−][src]
pub struct World { /* fields omitted */ }
Expand description
The ECS world storing Entities and components.
Implementations
Create an Entity without any components. To add components, see Self::insert().
Example
let mut world = World::new(); let entity = world.alloc(); world.insert(entity, (42_u32, true));
Remove an Entity and all its components from the world. To remove components, see Self::remove().
Example
let mut world = World::new(); let entity = world.alloc(); world.insert(entity, (42_u32, true)); world.free(entity);
Get an immutable reference to the component of the given type for an Entity.
Note that for repeated calls, map can be used to amortize the set-up costs.
Example
let mut world = World::new(); let entity = world.alloc(); world.insert(entity, (42_u32, true)); let comp = world.get::<u32>(entity).unwrap();
Get a mutable reference to the component of the given type for an Entity.
Note that for repeated calls, map can be used to amortize the set-up costs.
Example
let mut world = World::new(); let entity = world.alloc(); world.insert(entity, (42_u32, true)); let comp = world.get_mut::<u32>(entity).unwrap();
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for World
impl UnwindSafe for World