parse token setup line

This commit is contained in:
Martin HART 2020-10-30 11:56:24 +01:00
parent a50ec5d79b
commit 5c9aeabd03
1 changed files with 14 additions and 1 deletions

View File

@ -91,8 +91,21 @@ fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::Wor
Some(raw) => raw,
};
if raw_inst.is_empty() {
return Err("Thi line should not be empty !");
return Err("This line should not be empty !");
}
let mut setup = raw_setup.split_whitespace();
let pos_x = match setup.next() {
None => return Err("Could not read the first token of the setup line !"),
Some(raw) => raw,
};
let pos_y = match setup.next() {
None => return Err("Could not read the second token of the setup line !"),
Some(raw) => raw,
};
let orientation = match setup.next() {
None => return Err("Could not read the third token of the setup line !"),
Some(raw) => raw,
};
println!("{}", raw_setup);
println!("{}", raw_inst);
}