[][src]Crate numid

This crate provide the numid! macro for creating numerical id.

Syntax

This example is not tested
numid!([pub] struct NAME [(TYPE)] [-> CONSTANT]);

If not indicated, TYPE=u64 and CONSTANT=0.

Attributes

Attributes can be attached to the generated struct by placing them before the struct keyword (or pub if public).

Exemples


numid!(struct MyId -> 10);

fn main() {
    let id1 = MyId::new();
    let id2 = MyId::new();

    assert!(id2 > id1);
    assert_eq!(id1.value(), 11);
    assert_eq!(id2.value(), 12);
}

Trait implementations

The Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash and Debug traits automatically derived for the struct using the derive attribute. Additional traits can be derived by providing an explicit derive attribute.

The Display and Default traits are implemented for the struct. When calling default(), the struct is initialied with a new value instead of 0.

Macros

numid