Hi Rustaceans !
I'm wondering if its possible to create a macro that generate code based on a constant value.
I have this code :
const NB64BLOC: usize =5 //
...
for i in 0..NB64BLOC {
let (v, carry) = BigInt::overflowing_add(self.bits[i], _rhs.bits[i], c);
r.bits[i] = v;
c = carry;
}
and I wanted to generate :
let (v, carry) = BigInt::overflowing_add(self.bits[0], _rhs.bits[0], c);
r.bits[0] = v;
c = carry;
let (v, carry) = BigInt::overflowing_add(self.bits[1], _rhs.bits[1], c);
r.bits[1] = v;
c = carry;
let (v, carry) = BigInt::overflowing_add(self.bits[2], _rhs.bits[2], c);
r.bits[2] = v;
c = carry;
let (v, carry) = BigInt::overflowing_add(self.bits[3], _rhs.bits[3], c);
r.bits[3] = v;
c = carry;
let (v, carry) = BigInt::overflowing_add(self.bits[4], _rhs.bits[4], c);
r.bits[4] = v;
c = carry;
I know that it's basically loop unrolling and that the compiler should detect such a case. Nevertheless, I wanted to know if it is possible, to use this on more complicated operation.
Kind regards