2 unstable releases

0.2.0 May 16, 2022
0.1.0 May 12, 2022

#1970 in Procedural macros

Download history 11/week @ 2023-02-02 27/week @ 2023-02-09 20/week @ 2023-02-16 8/week @ 2023-02-23 10/week @ 2023-03-02 14/week @ 2023-03-09 9/week @ 2023-03-16 17/week @ 2023-03-23 12/week @ 2023-03-30 9/week @ 2023-04-06 15/week @ 2023-04-13 6/week @ 2023-04-20 2/week @ 2023-04-27 23/week @ 2023-05-04 13/week @ 2023-05-11 18/week @ 2023-05-18

58 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

~1.2–1.5MB
~38K SLoC