Rust supports tuple destructuring in pattern matching, which may be useful here and the other match:
Since you have if-else clauses here, it might make more sense to have a third enum member in addition to Keep and Drop, which indicates that we do nothing special with the roll.
I think it is better to document what the keep expression actually is here, so tacking on "1dXkY" would be useful.
Instead of unwrap
, you should make use of the features of the Result type. While you will see examples of Rust code around the internet littered with unwrap, you don't actually want to use it except under a few circumstances:
Add a third /
to get the Rustdoc working. It may also be good to more thoroughly describe what keep and drop mean here, namely that they mean keeping the highest or dropping the highest rolls.
Thank you for your pull request! I have made some comments. The most important one at the moment is getting rid of the unwrap()
calls so that errors are propagated up the chain instead of potentially causing a panic (though not sure how possible that actually is). The remainder are currently stylistic.