Tackles https://github.com/carols10cents/rustlings/issues/15 . I think this allows for varying levels of difficulty depending on a users background. But ideally people can move there way up from 1, 2, 3 (Numbers below).
1.
let mut result = 1;
for i in 1..x + 1 {
result *= i;
}
result
2.
match x {
0 | 1 => 1,
x => x * factorial(x - 1),
}
3.
(1..x + 1).product()
- Deciding not to have solutions in the tree right now, until I figure
out a more general way to handle that.
- The assertions work really great as tests, actually!
- Simplifying a few of the side points-- I think they deserve their own
exercises :)