#proc-macro #slice #hash #generate #representation #string #procedural

macro hashfn

A procedural macro to generate a hash representation of a function as a string slice

2 unstable releases

0.2.0 May 16, 2022
0.1.0 May 12, 2022

#1024 in Procedural macros

Download history 25/week @ 2024-02-19 21/week @ 2024-02-26 19/week @ 2024-03-11 10/week @ 2024-03-18 44/week @ 2024-04-01

73 downloads per month

MIT/Apache

8KB

hashfn

A procedural macro to generate a hash representation of a function as a string slice.

The hash is generated as a const with the same visibility as the function the macro is applied to.

Example:

use hashfn::hashfn;

#[hashfn(DO_SOMETHING)]
pub(crate) fn do_something() {}

// Will expand to
// pub(crate) const DO_SOMETHING: &str = "<hash>";
// pub(crate) fn do_something() {}

hashfn will generate the name of the constant if it is omitted:

use hashfn::hashfn;

#[hashfn]
pub(crate) fn do_something() {}

// Will expand to
// pub(crate) const DO_SOMETHING_HASH: &str = "<hash>";
// pub(crate) fn do_something() {}

lib.rs:

A procedural macro to generate a hash representation of a function as a string slice.

The hash is generated as a const with the same visibility as the function the macro is applied to.

Example:

use hashfn::hashfn;

#[hashfn(DO_SOMETHING)]
pub(crate) fn do_something() {}

// Will expand to
// pub(crate) const DO_SOMETHING: &str = "<hash>";
// pub(crate) fn do_something() {}

hashfn will generate the name of the constant if it is omitted:

use hashfn::hashfn;

#[hashfn]
pub(crate) fn do_something() {}

// Will expand to
// pub(crate) const DO_SOMETHING_HASH: &str = "<hash>";
// pub(crate) fn do_something() {}

Dependencies

~2MB
~43K SLoC