diff --git a/src/main.rs b/src/main.rs index cb3ab9d..4668dc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,20 +25,27 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result return Err("Could not read the first line of the config file !"), Some(raw) => raw, + None => return Err("Could not read the first line of the config file !"), }; let mut tokens = raw_line.split_whitespace(); let token1 = match tokens.next() { - None => return Err("Could not read the first token of the first line !"), Some(raw) => raw, + None => return Err("Could not read the first token of the first line !"), }; let token2 = match tokens.next() { - None => return Err("Could not read the second token of the first line !"), Some(raw) => raw, + None => return Err("Could not read the second token of the first line !"), }; - println!("{}, {}", token1, token2); - Ok(world::World { x: 5, y: 5 }) + let x: i32 = match token1.parse::() { + Ok(x) => x, + Err(err) => return Err("Could not convert token one from the first string to i32"), + }; + let y: i32 = match token2.parse::() { + Ok(x) => x, + Err(err) => return Err("Could not convert token two from the first string to i32"), + }; + Ok(world::World { x: x, y: y }) } /// Retrieve the content of a file and return it as a string.