Skip to content

Commit

Permalink
Add back missing Backup for SeaHash and WyHash rngs
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jan 11, 2024
1 parent 775094a commit 352b4e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion necsim/impls/no-std/src/cogs/rng/seahash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::marker::PhantomData;

use necsim_core::cogs::{MathsCore, PrimeableRng, RngCore};
use necsim_core::cogs::{Backup, MathsCore, PrimeableRng, RngCore};

use serde::{Deserialize, Serialize};

Expand All @@ -17,6 +17,13 @@ pub struct SeaHash<M: MathsCore> {
marker: PhantomData<M>,
}

#[contract_trait]
impl<M: MathsCore> Backup for SeaHash<M> {
unsafe fn backup_unchecked(&self) -> Self {
self.clone()
}
}

impl<M: MathsCore> RngCore<M> for SeaHash<M> {
type Seed = [u8; 8];

Expand Down
9 changes: 8 additions & 1 deletion necsim/impls/no-std/src/cogs/rng/wyhash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::marker::PhantomData;

use necsim_core::cogs::{MathsCore, PrimeableRng, RngCore};
use necsim_core::cogs::{Backup, MathsCore, PrimeableRng, RngCore};

use serde::{Deserialize, Serialize};

Expand All @@ -23,6 +23,13 @@ pub struct WyHash<M: MathsCore> {
marker: PhantomData<M>,
}

#[contract_trait]
impl<M: MathsCore> Backup for WyHash<M> {
unsafe fn backup_unchecked(&self) -> Self {
self.clone()
}
}

impl<M: MathsCore> RngCore<M> for WyHash<M> {
type Seed = [u8; 8];

Expand Down

0 comments on commit 352b4e7

Please sign in to comment.