From b4718494e3a1759286caca1dd34c01db6c2f1214 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 4 Aug 2023 22:03:30 +0200 Subject: refactor!: remove SomeThreadsafePtr & move variants to SomePtr BREAKING CHANGE: SomeThreadsafePtr has been removed and it's variants have been moved to SomePtr --- src/ptr.rs | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'src/ptr.rs') diff --git a/src/ptr.rs b/src/ptr.rs index bcaa566..1facc52 100644 --- a/src/ptr.rs +++ b/src/ptr.rs @@ -70,6 +70,14 @@ where #[cfg(feature = "factory")] #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] Factory(FactoryPtr), + + /// A smart pointer to a interface in the singleton scope. + ThreadsafeSingleton(ThreadsafeSingletonPtr), + + /// A smart pointer to a factory. + #[cfg(feature = "factory")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] + ThreadsafeFactory(ThreadsafeFactoryPtr), } impl SomePtr @@ -87,36 +95,11 @@ where cfg(feature = "factory"), cfg_attr(doc_cfg, doc(cfg(feature = "factory"))) ); -} - -/// Some threadsafe smart pointer. -#[derive(strum_macros::IntoStaticStr)] -pub enum SomeThreadsafePtr -where - Interface: 'static + ?Sized, -{ - /// A smart pointer to a interface in the transient scope. - Transient(TransientPtr), - /// A smart pointer to a interface in the singleton scope. - ThreadsafeSingleton(ThreadsafeSingletonPtr), - - /// A smart pointer to a factory. - #[cfg(feature = "factory")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] - ThreadsafeFactory(ThreadsafeFactoryPtr), -} - -impl SomeThreadsafePtr -where - Interface: 'static + ?Sized, -{ - create_as_variant_fn!(SomeThreadsafePtr, Transient, SomePtrError); - - create_as_variant_fn!(SomeThreadsafePtr, ThreadsafeSingleton, SomePtrError); + create_as_variant_fn!(SomePtr, ThreadsafeSingleton, SomePtrError); create_as_variant_fn!( - SomeThreadsafePtr, + SomePtr, ThreadsafeFactory, SomePtrError, cfg(feature = "factory"), -- cgit v1.2.3-18-g5258