From c2125db444961ed7da3cf19ab76d943d2a7bbc11 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Tue, 21 Mar 2023 08:25:15 -0400 Subject: [PATCH] added pub option --- utils/src/arc_pool.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/utils/src/arc_pool.rs b/utils/src/arc_pool.rs index b4fd8c88f..5fd782a1d 100644 --- a/utils/src/arc_pool.rs +++ b/utils/src/arc_pool.rs @@ -348,7 +348,7 @@ unsafe impl, const L: usize> Sync for PoolArcSwa /// ``` /// use zerotier_utils::arc_pool::{Pool, StaticPool, static_pool}; /// -/// static_pool!(StaticPool MyPools { +/// static_pool!(pub StaticPool MyPools { /// Pool, Pool<&u32, 12> /// }); /// @@ -384,6 +384,30 @@ macro_rules! __static_pool__ { } )* }; + (pub $m:ident $s:ident { $($($p:ident)::+<$t:ty$(, $l:tt)?>),+ $(,)?}) => { + pub struct $s {} + $( + impl $m<$t$(, $l)?> for $s { + #[inline(always)] + unsafe fn get_static_pool() -> *const () { + static POOL: $($p)::+<$t$(, $l)?> = $($p)::+::new(); + (&POOL as *const $($p)::+<$t$(, $l)?>).cast() + } + } + )* + }; + (pub $m:ident::$n:ident $s:ident { $($($p:ident)::+<$t:ty$(, $l:tt)?>),+ $(,)?}) => { + pub struct $s {} + $( + impl $m::$n<$t$(, $l)?> for $s { + #[inline(always)] + unsafe fn get_static_pool() -> *const () { + static POOL: $($p)::+<$t$(, $l)?> = $($p)::+::new(); + (&POOL as *const $($p)::+<$t$(, $l)?>).cast() + } + } + )* + }; } pub use __static_pool__ as static_pool;