diff options
| author | HarmoGlace <23212967+HarmoGlace@users.noreply.github.com> | 2023-04-13 14:38:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-13 14:38:51 +0200 |
| commit | e11bd2a193f170bebbb2723acc6c52bab2106b0c (patch) | |
| tree | 3bfb42b678ae6d4633d80ddaeaddb18d919c3de2 /src | |
| parent | 89cf4054d61d296245b34a20f9ad0b749c0f83e2 (diff) | |
Add factorial, permutation and binomial to calculation functions (#639)
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval/cast.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/eval/cast.rs b/src/eval/cast.rs index 7b306633..e2ae115f 100644 --- a/src/eval/cast.rs +++ b/src/eval/cast.rs @@ -115,6 +115,21 @@ cast_to_value! { } cast_from_value! { + u64, + int: i64 => int.try_into().map_err(|_| { + if int < 0 { + "number must be at least zero" + } else { + "number too large" + } + })?, +} + +cast_to_value! { + v: u64 => Value::Int(v as i64) +} + +cast_from_value! { NonZeroUsize, int: i64 => int .try_into() |
