Catch the first ligne of the config file
or throw a error !
This commit is contained in:
parent
430e706831
commit
bbcbfd4d41
10
src/main.rs
10
src/main.rs
@ -22,10 +22,12 @@ mod world;
|
||||
|
||||
/// Parse the config file, generate the world and robot pool.
|
||||
fn parse_config(raw_conf: String, pool: &Vec<robot::Robot>) -> Result<world::World, &'static str> {
|
||||
// test exemple, i am currently writting the real code.
|
||||
// This function return the map OR an error inside a Result so we
|
||||
// can catch error using '?' in main
|
||||
// we also create robots here and put them into the pool.
|
||||
let mut lines = raw_conf.lines();
|
||||
// The first line of the config file should be the World.
|
||||
let raw_map: &str = match lines.next() {
|
||||
None => return Err("Could not read the first line of the config file !"),
|
||||
Some(raw) => raw,
|
||||
};
|
||||
Ok(world::World { x: 5, y: 5 })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user