aboutsummaryrefslogtreecommitdiff
path: root/src/ptr.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-10-03 20:23:26 +0200
committerHampusM <hampus@hampusmat.com>2022-10-03 20:45:32 +0200
commit97c789e38bb8e61389a3808d241689e623144344 (patch)
tree4cbaee424bfcb1b69a523be9664e48e5264f3d4b /src/ptr.rs
parent03d3898a05592eb83b7a16609dba46d0b293790e (diff)
refactor: remove relying on Rust nightly for better handling of features
Diffstat (limited to 'src/ptr.rs')
-rw-r--r--src/ptr.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/ptr.rs b/src/ptr.rs
index 824b086..46418d1 100644
--- a/src/ptr.rs
+++ b/src/ptr.rs
@@ -2,7 +2,6 @@
use std::rc::Rc;
use std::sync::Arc;
-use feature_macros::feature_specific;
use paste::paste;
use crate::errors::ptr::{SomePtrError, SomeThreadsafePtrError};
@@ -17,11 +16,13 @@ pub type SingletonPtr<Interface> = Rc<Interface>;
pub type ThreadsafeSingletonPtr<Interface> = Arc<Interface>;
/// A smart pointer to a factory.
-#[feature_specific("factory")]
+#[cfg(feature = "factory")]
+#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub type FactoryPtr<FactoryInterface> = Rc<FactoryInterface>;
/// A threadsafe smart pointer to a factory.
-#[feature_specific("factory")]
+#[cfg(feature = "factory")]
+#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub type ThreadsafeFactoryPtr<FactoryInterface> = Arc<FactoryInterface>;
macro_rules! create_as_variant_fn {
@@ -37,7 +38,7 @@ macro_rules! create_as_variant_fn {
"# Errors\n"
"Will return Err if it's not the `" [<$variant>] "` variant."
]
- $(#[$attrs]),*
+ $(#[$attrs])*
pub fn [<$variant:snake>](self) -> Result<[<$variant Ptr>]<Interface>, [<$enum Error>]>
{
if let $enum::$variant(ptr) = self {
@@ -79,7 +80,12 @@ where
create_as_variant_fn!(SomePtr, Singleton);
- create_as_variant_fn!(SomePtr, Factory, feature_specific("factory"));
+ create_as_variant_fn!(
+ SomePtr,
+ Factory,
+ cfg(feature = "factory"),
+ cfg_attr(doc_cfg, doc(cfg(feature = "factory")))
+ );
}
/// Some threadsafe smart pointer.
@@ -111,6 +117,7 @@ where
create_as_variant_fn!(
SomeThreadsafePtr,
ThreadsafeFactory,
- feature_specific("factory")
+ cfg(feature = "factory"),
+ cfg_attr(doc_cfg, doc(cfg(feature = "factory")))
);
}