mirror of
https://github.com/Zenithsiz/dynatos.git
synced 2026-02-07 12:44:53 +00:00
Added dynatos_util::hash_of
This commit is contained in:
parent
445fd1c89a
commit
58b235f55f
@ -18,7 +18,10 @@ pub use self::{
|
||||
// Imports
|
||||
use {
|
||||
js_sys::Reflect,
|
||||
std::fmt,
|
||||
std::{
|
||||
fmt,
|
||||
hash::{self, Hasher},
|
||||
},
|
||||
wasm_bindgen::{JsCast, JsValue},
|
||||
};
|
||||
|
||||
@ -76,3 +79,10 @@ pub impl js_sys::Object {
|
||||
value.dyn_into().map_err(GetError::WrongType)
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates the hash of a value using the default hasher
|
||||
pub fn hash_of<T: hash::Hash>(t: &T) -> u64 {
|
||||
let mut s = hash::DefaultHasher::new();
|
||||
t.hash(&mut s);
|
||||
s.finish()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user