Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! We don't use `rand` because that is too many things for us.
//!
//! `oorandom` is used instead, but it's missing these two utilities.
//! Switching to `fastrand` or our own small PRNG may be good because only xor-shift is needed.

pub fn shuffle<T>(slice: &mut [T], mut rand_index: impl FnMut(usize) -> usize) {
    let mut remaining = slice.len() - 1;
    while remaining > 0 {
        let index = rand_index(remaining);
        slice.swap(remaining, index);
        remaining -= 1;
    }
}

pub fn seed() -> u64 {
    use std::hash::{BuildHasher, Hasher};
    #[allow(clippy::disallowed_types)]
    std::collections::hash_map::RandomState::new().build_hasher().finish()
}
HOOK: Once = Once::new(); SET_HOOK.call_once(set_hook); with_ctx(|ctx| ctx.push(frame)); PanicContext { _priv: () } } fn with_ctx(f: impl FnOnce(&mut Vec<String>)) { thread_local! { static CTX: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) }; } CTX.with(|ctx| f(&mut ctx.borrow_mut())); }