Catch the first ligne of the config file

or throw a error !
This commit is contained in:
Martin HART 2020-10-28 13:09:07 +01:00
parent 430e706831
commit bbcbfd4d41
1 changed files with 6 additions and 4 deletions

View File

@ -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 })
}