Skip to content

A rust library that provides loops which are fully or partially unrolled at compile time.

License

Notifications You must be signed in to change notification settings

millardjn/typenum_loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

typenum_loops

A library that provides loops which are fully or partially unrolled at compile time.

extern crate typenum;
extern crate typenum_loops;

use typenum::{U4, U6};
use typenum_loops::Loop;

fn main(){
    let arr: &mut[usize] = &mut[0; 4];
    // for i in 0..4 {arr[i] = i} fully unrolled by 4
    U4::full_unroll(&mut |i| arr[i] = i);
    
    let arr2: &mut[usize] = &mut[0; 13];
    // for i in 0..13 {arr2[i] = i} unrolled by 6
    U6::partial_unroll(13, &mut |i, _| arr2[i] = i);
}

Note: Very large closures may not be inlined despite attempts to trick llvm by using an empty wrapper fn.

License

MIT

About

A rust library that provides loops which are fully or partially unrolled at compile time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages