My C++ code creates a hash of a string using the standard functional library. I would like to port this function to Ruby, but as you can see, I lay my hashing into the strong, mighty hands of the C++ library.
Is there a direct equivalent in Ruby?
#include <functional>
int hashString(std::string_view str) {
std::hash<std::string_view> hash_function;
size_t h = hash_function(str);
return 0x7FFFFFFFL & h;
}