Skip to content

maksimsco/static_index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proc macro for generating unique static indexes in a range 0..N. Ordering of indexes is not guaranteed.

Build Status

Example

use static_index::{codegen::static_index, codegen::StaticIndex, Indexable};

struct A;
struct B;
struct C;

#[derive(StaticIndex)]
struct D;

struct E;

static_index!(A, B, C);

static_index!(E);

fn main() {
    assert_eq!(1, <A as Indexable>::INDEX);
    assert_eq!(2, <B as Indexable>::INDEX);
    assert_eq!(3, <C as Indexable>::INDEX);
    assert_eq!(0, <D as Indexable>::INDEX);
    assert_eq!(4, <E as Indexable>::INDEX);
}

About

Proc macro for generating unique static indexes in a range 0..N

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages