diff options
Diffstat (limited to 'CLI/rust/src/game_of_life/opts.rs')
| -rw-r--r-- | CLI/rust/src/game_of_life/opts.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life/opts.rs b/CLI/rust/src/game_of_life/opts.rs index c0ece98..5e52715 100644 --- a/CLI/rust/src/game_of_life/opts.rs +++ b/CLI/rust/src/game_of_life/opts.rs @@ -37,4 +37,13 @@ pub(crate) mod validators { Err(e) => Err(e.to_string()), } } + + /// Validator to check if delay value is positive + pub(crate) fn is_positive(val: &str) -> Result<(), String> { + match val.parse::<i16>() { + Ok(n) if n.is_positive() => Ok(()), + Ok(_) => Err(String::from("must be postive value (so far)")), + Err(e) => Err(e.to_string()), + } + } } |
