Skip to main content

java_string_hash

Function java_string_hash 

Source
pub fn java_string_hash(s: &str) -> i32
Expand description

Computes a hash code compatible with Java’s String.hashCode().

Java’s algorithm: s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] where n is the length of the string.

This uses wrapping arithmetic to match Java’s int overflow behavior.