Add function documentation
All checks were successful
CI / Formatting (push) Successful in 1m30s

This commit is contained in:
Michael Bradley 2025-05-19 22:19:04 -04:00
parent fc95857824
commit 6a151397de
Signed by: MichaelBradley
SSH key fingerprint: SHA256:BKO2eI2LPsCbQS3n3i5SdwZTAIV3F1lHezR07qP+Ob0
7 changed files with 21 additions and 1 deletions

View file

@ -2,10 +2,12 @@ use std::hash::{DefaultHasher, Hash, Hasher};
use bevy::prelude::*;
/// Value with which to initialize the PRNG
#[derive(Clone, Resource)]
pub struct Seed(u64);
impl From<String> for Seed {
/// Attempt to parse as an integer, fall back to hashing string
fn from(value: String) -> Self {
Self(value.parse::<u64>().unwrap_or_else(|_| {
let mut state = DefaultHasher::new();
@ -16,6 +18,7 @@ impl From<String> for Seed {
}
impl From<Seed> for [u8; 8] {
/// Convert to a u8 array for ingestion by random number generator
fn from(value: Seed) -> Self {
value.0.to_le_bytes()
}