From 194d6f5df211c86f0ba9b9909fc1b8bdf7502ecf Mon Sep 17 00:00:00 2001 From: Martin HART Date: Wed, 28 Oct 2020 16:50:49 +0100 Subject: [PATCH] Remove .unwrap() shit --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index d1ae7d2..cb3ab9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,9 +29,15 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result 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 }) }