From 8a1e18169bf01809554de40a4435ed1c0725d712 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 8 Sep 2024 21:30:35 -0500 Subject: [PATCH] generic type issues --- docs/src/rust/lib/ranges.rst | 3 ++- rust/src/include/ranges.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/src/rust/lib/ranges.rst b/docs/src/rust/lib/ranges.rst index b3780da5..59d6fba9 100644 --- a/docs/src/rust/lib/ranges.rst +++ b/docs/src/rust/lib/ranges.rst @@ -10,13 +10,14 @@ Includes - :external:rust:fn:`num_traits::one` - :external:rust:fn:`num_traits::zero` - :external:rust:trait:`std::cmp::PartialOrd` +- :external:rust:trait:`std::marker::Copy` .. rust:fn:: pub fn ranges::range_entry3(start: I, idx: I, step: I) -> I where I: NumAssign Returns the factorial of a given number. Note that it only accepts a ``u8`` because any number that requires a larger type is *guaranteed* to overflow. -.. rust:fn:: pub fn ranges::range_entry4(start: I, stop: I, idx: I, step: I) -> Option where I: NumAssign + PartialOrd +.. rust:fn:: pub fn ranges::range_entry4(start: I, stop: I, idx: I, step: I) -> Option where I: NumAssign + PartialOrd + Copy Returns the number of ways to choose r items from a set of n. diff --git a/rust/src/include/ranges.rs b/rust/src/include/ranges.rs index b5b8cd40..1ec2597f 100644 --- a/rust/src/include/ranges.rs +++ b/rust/src/include/ranges.rs @@ -1,4 +1,5 @@ use std::cmp::PartialOrd; +use std::marker::Copy; use num_traits::{one,zero,NumAssign}; @@ -9,7 +10,7 @@ where I: NumAssign } pub fn range_entry4(start: I, stop: I, idx: I, step: I) -> Option -where I: NumAssign + PartialOrd +where I: NumAssign + PartialOrd + Copy { let length = if step > zero() && start < stop { one::() + (stop - one() - start) / step