From 5c9aeabd033cd090e7810546a94fa2dc264788a8 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Fri, 30 Oct 2020 11:56:24 +0100 Subject: [PATCH] parse token setup line --- src/main.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c90b42f..d452135 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,8 +91,21 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result 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); }