Function string_hash

Source
pub fn string_hash(s: &str) -> usize
Expand description

Computes a hash for a UTF-8 string slice using the method described by Bruno Haible.

This function iterates over each byte of the string, updating the hash value at each step. It is suitable for hashing Rust string slices (&str), not raw C pointers.

See: https://www.haible.de/bruno/hashfunc.html

ยงExamples

use text_fx::hash::string_hash;

let hash = string_hash("hello");
assert_eq!(hash, string_hash("hello"));
assert_ne!(hash, string_hash("world"));