unroll-fn

Crates.iounroll-fn
lib.rsunroll-fn
version0.1.1
sourcesrc
created_at2022-03-12 13:26:29.076281
updated_at2022-03-12 13:34:42.521857
descriptionA generic unrollling function.
homepage
repositoryhttps://github.com/kitegi/unroll/
max_upload_size
id548762
size3,733
sarah quiƱones (sarah-quinones)

documentation

README

unroll-fn

An generic unroll function that takes a callable and calls it N times.

[dependencies]
unroll-fn = "0.1"
use unroll::unroll;

fn main() {
    let arr = [1, 10, 100];
    let mut sum = 0;

    // Expands to:
    //
    //     sum += arr[0];
    //     sum += arr[1];
    //     sum += arr[2];
    //
    unroll::<3, _>(|i| sum += arr[i]);
    assert_eq!(sum, 111);
}
Commit count: 10

cargo fmt