https://github.com/johnnynotsolucky/hashfn
A procedural macro to generate a hash representation of a function as a string slice
https://github.com/johnnynotsolucky/hashfn
proc-macro proc-macro-attributes rust
Last synced: 4 months ago
JSON representation
A procedural macro to generate a hash representation of a function as a string slice
- Host: GitHub
- URL: https://github.com/johnnynotsolucky/hashfn
- Owner: johnnynotsolucky
- License: other
- Created: 2022-05-11T20:27:35.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-16T07:30:30.000Z (over 3 years ago)
- Last Synced: 2025-09-22T23:23:19.541Z (5 months ago)
- Topics: proc-macro, proc-macro-attributes, rust
- Language: Rust
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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 = "";
// 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 = "";
// pub(crate) fn do_something() {}
```