error handling for position
This commit is contained in:
parent
5d1c515192
commit
389cfe5f10
|
@ -9,6 +9,11 @@ impl From<String> 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 }
|
||||
|
|
Loading…
Reference in New Issue