about summary refs log tree commit diff
path: root/src/notd/rand.rs
blob: 95c8f0baba35bb946f2d3705ce78d481da3dbc84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::{
    collections::hash_map::DefaultHasher,
    hash::{Hash, Hasher},
};

pub fn random_from_seed(seed: u64) -> u64 {
    let mut hasher = DefaultHasher::new();
    seed.hash(&mut hasher);
    hasher.finish()
}

pub fn seed_from_name(name: &str) -> u64 {
    let mut hasher = DefaultHasher::new();
    name.hash(&mut hasher);
    hasher.finish() as u64
}