Skip to content

Commit

Permalink
generic type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 9, 2024
1 parent 0c3a0ce commit 8a1e181
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/src/rust/lib/ranges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<I>(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<I>(start: I, stop: I, idx: I, step: I) -> Option<I> where I: NumAssign + PartialOrd
.. rust:fn:: pub fn ranges::range_entry4<I>(start: I, stop: I, idx: I, step: I) -> Option<I> where I: NumAssign + PartialOrd + Copy
Returns the number of ways to choose r items from a set of n.

Expand Down
3 changes: 2 additions & 1 deletion rust/src/include/ranges.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::cmp::PartialOrd;
use std::marker::Copy;

use num_traits::{one,zero,NumAssign};

Expand All @@ -9,7 +10,7 @@ where I: NumAssign
}

pub fn range_entry4<I>(start: I, stop: I, idx: I, step: I) -> Option<I>
where I: NumAssign + PartialOrd
where I: NumAssign + PartialOrd + Copy
{
let length = if step > zero() && start < stop {
one::<I>() + (stop - one() - start) / step
Expand Down

0 comments on commit 8a1e181

Please sign in to comment.