mod utils; use wasm_bindgen::prelude::*; use uwurandom_rs::StateMachine; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] struct Uwurandom(StateMachine); #[wasm_bindgen] impl Uwurandom { pub fn new() -> Self { Self(StateMachine::new(rand::thread_rng())) } pub fn generate(&mut self) -> char { let (machine, generated) = self.0.generate(rand::thread_rng()); self.0 = machine; generated } }