Remove .unwrap() shit

This commit is contained in:
Martin HART 2020-10-28 16:50:49 +01:00
parent e4001c99c7
commit 194d6f5df2
1 changed files with 9 additions and 3 deletions

View File

@ -29,9 +29,15 @@ fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::Wor
Some(raw) => raw,
};
let mut tokens = raw_line.split_whitespace();
let token1 = tokens.next();
let token2 = tokens.next();
println!("{}, {}", token1.unwrap(), token2.unwrap());
let token1 = match tokens.next() {
None => return Err("Could not read the first token of the first line !"),
Some(raw) => raw,
};
let token2 = match tokens.next() {
None => return Err("Could not read the second token of the first line !"),
Some(raw) => raw,
};
println!("{}, {}", token1, token2);
Ok(world::World { x: 5, y: 5 })
}