6 releases

0.1.6 Oct 30, 2020
0.1.5 Oct 30, 2020
0.1.4 Apr 3, 2019
0.1.2 Dec 18, 2018

#993 in Algorithms

41 downloads per month
Used in 2 crates

Apache-2.0 OR MIT

15KB
134 lines

A series of fixed hash types.

Constructors

This crate provides a series of macros that used to construct fixed hashes in compile time.

The input is a hexadecimal string literal with 0x prefix. Completed strings or trimmed strings both are allowed.

And you can use any number of _ in the string literal to separate it for more readable.

Examples

use numext_fixed_hash::{h128, H128};

const H128_VAL: H128 = h128!("0x123456789abcdef");

fn main () -> ::std::io::Result<()> {
    let x1 = h128!("0x123456789abcdef");
    let x2 = h128!("0x00000000000000000123456789abcdef");
    let y = H128::from_trimmed_hex_str("123456789abcdef").unwrap();
    assert_eq!(x1, y);
    assert_eq!(x2, y);
    assert_eq!(H128_VAL, y);
    Ok(())
}

Dependencies

~1.1–1.8MB
~38K SLoC