Skip to content

Commit

Permalink
bindings/rust/src/lib.rs: fix an overflow panic in debug build.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Jan 28, 2022
1 parent 48d66a7 commit 88330f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use core::any::Any;
use core::mem::MaybeUninit;
use core::ptr;
use core::sync::atomic::*;
use std::num::Wrapping;
use std::sync::{mpsc::channel, Arc, Barrier};
use zeroize::Zeroize;

Expand Down Expand Up @@ -1673,14 +1674,14 @@ macro_rules! pippenger_mult_impl {
let wg = Arc::new((Barrier::new(2), AtomicUsize::new(nslices)));

let (mut delta, mut rem) =
(npoints / nslices + 1, npoints % nslices);
(npoints / nslices + 1, Wrapping(npoints % nslices));
let mut x = 0usize;
while x < npoints {
let out = &mut ret.points[x];
let inp = &points[x];

delta -= (rem == 0) as usize;
rem -= 1;
delta -= (rem == Wrapping(0)) as usize;
rem -= Wrapping(1);
x += delta;

let wg = wg.clone();
Expand Down

0 comments on commit 88330f8

Please sign in to comment.