Skip to content

Commit

Permalink
review fix: fix DbNamespaceId enum to be wasm only and inline `for_…
Browse files Browse the repository at this point in the history
…test_with_id`
  • Loading branch information
shamardy committed Sep 25, 2024
1 parent de645bd commit 4e46c35
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mm2src/mm2_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use derive_more::Display;
use rand::{thread_rng, Rng};
#[cfg(target_arch = "wasm32")] use derive_more::Display;
#[cfg(target_arch = "wasm32")] use rand::{thread_rng, Rng};

pub mod data_asker;
pub mod event_dispatcher;
pub mod mm_ctx;

#[cfg(target_arch = "wasm32")]
#[derive(Clone, Copy, Display, PartialEq, Default)]
pub enum DbNamespaceId {
#[display(fmt = "MAIN")]
Expand All @@ -14,11 +15,13 @@ pub enum DbNamespaceId {
Test(u64),
}

#[cfg(target_arch = "wasm32")]
impl DbNamespaceId {
pub fn for_test() -> DbNamespaceId {
let mut rng = thread_rng();
DbNamespaceId::Test(rng.gen())
}

#[inline(always)]
pub fn for_test_with_id(id: u64) -> DbNamespaceId { DbNamespaceId::Test(id) }
}

0 comments on commit 4e46c35

Please sign in to comment.