Related to the #![feature(loop_hints)] attributes: #156874
It would be nice if the N in #[unroll(N)] could take an arbitrary const expression, not just an integer literal:
fn foo<const UNROLL_FACTOR: usize>() {
#[unroll(UNROLL_FACTOR)]
loop {
...
}
}
If that's not possible for technical reasons, another possibility would be a std::hint::unroll function which takes a const parameter and a closure:
fn foo<const UNROLL_FACTOR: usize>() {
std::hint::unroll::<UNROLL_FACTOR>(|| loop {
...
});
}
This would make it easier to experiment with different unroll factors without having to duplicate the same function for each unroll factor
Related to the
#![feature(loop_hints)]attributes: #156874It would be nice if the
Nin#[unroll(N)]could take an arbitraryconstexpression, not just an integer literal:If that's not possible for technical reasons, another possibility would be a
std::hint::unrollfunction which takes aconstparameter and a closure:This would make it easier to experiment with different unroll factors without having to duplicate the same function for each unroll factor