add mut to the pool O_o

This commit is contained in:
Martin HART 2020-10-28 16:17:34 +01:00
parent 0a63ab5b53
commit 9d0b96b4d7
1 changed files with 6 additions and 5 deletions

View File

@ -21,17 +21,18 @@ mod robot;
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> {
let mut lines = raw_conf.lines();
fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> {
let mut lines = conf.lines();
// The first line of the config file should be the World.
let raw_line: &str = match lines.next() {
None => return Err("Could not read the first line of the config file !"),
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 })
}
@ -57,8 +58,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?;
let robot_pool: Vec<robot::Robot> = Vec::new();
let world: world::World = parse_config(raw_conf, &robot_pool)?;
let mut robot_pool: Vec<robot::Robot> = Vec::new();
let world: world::World = parse_config(raw_conf, &mut robot_pool)?;
Ok(())
}