From 430e7068317f8ea5d1c078e4694b4afa266bbdd1 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Wed, 28 Oct 2020 12:36:56 +0100 Subject: [PATCH] Prototype of the parsing_config() func --- src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.rs b/src/main.rs index 71a1e16..344b600 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,16 @@ use std::fs; use std::io; mod robot; +mod world; + +/// Parse the config file, generate the world and robot pool. +fn parse_config(raw_conf: String, pool: &Vec) -> Result { + // 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. + Ok(world::World { x: 5, y: 5 }) +} /// Retrieve the content of a file and return it as a string. fn open_file(filename: &str) -> io::Result { @@ -42,6 +52,7 @@ 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 = parse_config(raw_conf, &robot_pool)?; Ok(()) }