File: fix-integer-overflow-in-test.patch

package info (click to toggle)
rust-itertools 0.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,196 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--- rust-itertools-0.13.0.orig/tests/test_std.rs
+++ rust-itertools-0.13.0/tests/test_std.rs
@@ -21,6 +21,7 @@ use rand::{
 };
 use rand::{seq::SliceRandom, thread_rng};
 use std::{cmp::min, fmt::Debug, marker::PhantomData};
+use std::convert::TryInto;
 
 #[test]
 fn product3() {
@@ -1050,7 +1051,9 @@ fn binomial(n: usize, k: usize) -> usize
     if k > n {
         0
     } else {
-        (n - k + 1..=n).product::<usize>() / (1..=k).product::<usize>()
+        let n = n as u64;
+        let k = k as u64;
+        ((n - k + 1..=n).product::<u64>() / (1..=k).product::<u64>()).try_into().unwrap()
     }
 }