diff options
| author | a14m <[email protected]> | 2021-04-03 02:15:09 +0200 |
|---|---|---|
| committer | a14m <[email protected]> | 2021-04-03 02:15:09 +0200 |
| commit | d690299c83b28fc380c5eb37f4e978e6a6411758 (patch) | |
| tree | d4bdf8d404fc1db6735fccd5d84179e095908be0 /CLI/rust/src/game_of_life/opts.rs | |
| parent | c6271541765b06c8437491e012de19da08b0ab3e (diff) | |
Add missing docs
Diffstat (limited to 'CLI/rust/src/game_of_life/opts.rs')
| -rw-r--r-- | CLI/rust/src/game_of_life/opts.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life/opts.rs b/CLI/rust/src/game_of_life/opts.rs index f32c4a8..7431b2c 100644 --- a/CLI/rust/src/game_of_life/opts.rs +++ b/CLI/rust/src/game_of_life/opts.rs @@ -8,6 +8,7 @@ use mocktopus::macros::mockable; pub(crate) mod validators; #[derive(Debug, Clone)] +/// Parsed options for generating a Game of Life simulation pub(crate) struct Opts { pub seed: usize, pub input: Option<String>, @@ -20,6 +21,17 @@ pub(crate) struct Opts { #[cfg_attr(test, mockable)] impl Opts { + /// Parse args, set the defaults for the dynamic options (like `seed`, `width`, `height`) + /// and validate the conflicting options (same live/dead cell configured). + /// + /// The dynamic options that can be set are: + /// - `seed` is set to random if it's not provided. + /// - `width` is set to the current terminal screen width when not provided. + /// - `height` is set to the current terminal screen height -2 when not provided. + /// + /// The parsed options are typed into the correct types used (from strings) + /// and validated to make sure that they work together (live/dead cells must be different) + /// and the delay between renders must be a positive integer (milliseconds). pub fn from(args: ArgMatches) -> Result<Opts, Error> { // Set the seed to a random generated number as default if not provided let rnd = thread_rng().gen_range(0..1_000_000); |
