16 lines
424 B
Rust
16 lines
424 B
Rust
use std::hash::{DefaultHasher, Hash, Hasher};
|
|
|
|
#[derive(Clone, Copy)]
|
|
pub struct Seed(pub i64);
|
|
|
|
impl From<&str> for Seed {
|
|
fn from(value: &str) -> Self {
|
|
// TODO replace with a deterministic hasher (the same as vanilla?)
|
|
let mut hasher = DefaultHasher::new();
|
|
value.hash(&mut hasher);
|
|
|
|
// TODO use cast_signed once the feature is stabilized.
|
|
Self(hasher.finish() as i64)
|
|
}
|
|
}
|