exemple token

This commit is contained in:
Martin HART 2020-10-28 14:06:03 +01:00
parent bbcbfd4d41
commit 0a63ab5b53
1 changed files with 6 additions and 2 deletions

View File

@ -24,10 +24,14 @@ mod world;
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> {
let mut lines = raw_conf.lines(); let mut lines = raw_conf.lines();
// The first line of the config file should be the World. // The first line of the config file should be the World.
let raw_map: &str = match lines.next() { let raw_line: &str = match lines.next() {
None => return Err("Could not read the first line of the config file !"), None => return Err("Could not read the first line of the config file !"),
Some(raw) => raw, Some(raw) => raw,
}; };
let raw_token = raw_line.split_whitespace();
let token1 = raw_token.next();
let token2 = raw_token.next();
// Need to check if the robots fit in the World.
Ok(world::World { x: 5, y: 5 }) Ok(world::World { x: 5, y: 5 })
} }
@ -54,7 +58,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?; let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
let robot_pool: Vec<robot::Robot> = Vec::new(); let robot_pool: Vec<robot::Robot> = Vec::new();
let world = parse_config(raw_conf, &robot_pool)?; let world: world::World = parse_config(raw_conf, &robot_pool)?;
Ok(()) Ok(())
} }