diff --git a/src/main.rs b/src/main.rs index d452135..b327483 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,6 +93,7 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result return Err("Could not read the first token of the setup line !"), @@ -106,6 +107,22 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result return Err("Could not read the third token of the setup line !"), Some(raw) => raw, }; + // Convert values of the setup line + let r_x = match pos_x.parse::() { + Err(_) => return Err("Could not convert the first token of the setup ligne to i32 !"), + Ok(raw) => raw, + }; + let r_y = match pos_y.parse::() { + Err(_) => return Err("Could not convert the second token of the setup ligne to i32 !"), + Ok(raw) => raw, + }; + let r_o = match orientation { + "N" => robot::Orientation::N, + "E" => robot::Orientation::E, + "S" => robot::Orientation::S, + "W" => robot::Orientation::W, + _ => return Err("The third token of the setup line do not match any orientations !"), + }; println!("{}", raw_setup); println!("{}", raw_inst); }