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.
|
/// 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> {
|
fn parse_config(raw_conf: String, pool: &Vec<robot::Robot>) -> Result<world::World, &'static str> {
|
||||||
// test exemple, i am currently writting the real code.
|
let mut lines = raw_conf.lines();
|
||||||
// This function return the map OR an error inside a Result so we
|
// The first line of the config file should be the World.
|
||||||
// can catch error using '?' in main
|
let raw_map: &str = match lines.next() {
|
||||||
// we also create robots here and put them into the pool.
|
None => return Err("Could not read the first line of the config file !"),
|
||||||
|
Some(raw) => raw,
|
||||||
|
};
|
||||||
Ok(world::World { x: 5, y: 5 })
|
Ok(world::World { x: 5, y: 5 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user