From 389cfe5f1066feab22c09098e01fd4f40537cab9 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Tue, 14 Apr 2020 00:37:02 +0100 Subject: [PATCH] error handling for position --- src/position.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/position.rs b/src/position.rs index 1b946c9..f34d5de 100644 --- a/src/position.rs +++ b/src/position.rs @@ -9,6 +9,11 @@ impl From for Position { // e.g. "2,5" let xy: Vec<&str> = string.split(',').collect(); let x = xy[0].parse().unwrap(); + + if xy.len() < 2 { + panic!("Bad position : {}", string); + } + let y = xy[1].parse().unwrap(); Position { x, y }