From 9d0b96b4d71e1ee4112c9310b7198df8bc3380ae Mon Sep 17 00:00:00 2001 From: Martin HART Date: Wed, 28 Oct 2020 16:17:34 +0100 Subject: [PATCH] add mut to the pool O_o --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 81876d4..e994322 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) -> Result { - let mut lines = raw_conf.lines(); +fn parse_config(conf: String, pool: &mut Vec) -> Result { + 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> { let raw_conf = open_file(matches.value_of("file").unwrap_or("two_robots.txt"))?; - let robot_pool: Vec = Vec::new(); - let world: world::World = parse_config(raw_conf, &robot_pool)?; + let mut robot_pool: Vec = Vec::new(); + let world: world::World = parse_config(raw_conf, &mut robot_pool)?; Ok(()) }