HeroesGrave/ecs-rs — pull request #7 by jakerr (2014-10-05 20:21:04+00:00)
Title: Remove lock boolean flag from World and enforce config via WorldBuilder

:warning: This is a breaking change.

This was kind of an experiment just out of my own curiosity to see if I could make the correctness check that lock provided but at compile time just by moving the configuration methods to a builder struct which would be consumed by it's build method.

Feel free to take it if you like, or give some feedback if you have some better ideas for where you want to take the API :)

Reasoning:

Using a flag meant failing the task when misused where this API prevents
misuse at compile time.
This makes trying to access configuration methods after building the world
a compilation error because the WorldBuilder is consumed by build.
It also prevents trying to call update etc. before configuration is complete
because the World::new is made private and World are always made with
a builder.

Example of what it disallows at compile time:
```rust
#![feature(phase)]

extern crate debug;
#[phase(plugin, link)]
extern crate ecs;

use ecs::world::World;
use ecs::world::WorldBuilder;
use ecs::component;
use ecs::component::ComponentList;

component!(MyComponent { a: int })

fn main() {
let mut w = WorldBuilder::new();
w.register_component::();
let wo = w.build();
println!("{:?}", wo)

w.register_component::(); // <-- No risk of registering more after build.
// main.rs:24:5: 24:6 error: use of moved value: `w`
// w.register_component::();
// ^
}

```