From 4e46c358ca4d742c3829e327cdd640de17f77e98 Mon Sep 17 00:00:00 2001 From: shamardy Date: Wed, 25 Sep 2024 15:37:37 +0300 Subject: [PATCH] review fix: fix `DbNamespaceId` enum to be wasm only and inline `for_test_with_id` --- mm2src/mm2_core/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm2src/mm2_core/src/lib.rs b/mm2src/mm2_core/src/lib.rs index 3c0a118430..88b0fd5c81 100644 --- a/mm2src/mm2_core/src/lib.rs +++ b/mm2src/mm2_core/src/lib.rs @@ -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")] @@ -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) } }