1 2 3 4 5 6 7 8 9 10
use num::BigInt; pub fn next(v: &BigInt) -> BigInt { /*let t: BigUint = v | (v - 1); (t + 1) | (((!t & -!t) - 1) >> (v.trailing_zeros() + 1))*/ let t: BigInt = (v | (v - 1u32)) + 1u32; &t | ((((&t & -&t) / (v & -v)) >> 1) - 1u32) }