aboutsummaryrefslogtreecommitdiff
path: root/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros.rs')
-rw-r--r--src/macros.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/macros.rs b/src/macros.rs
index 7d2cf6a..7af64bc 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -50,13 +50,15 @@ macro_rules! iprintln {
/// }
/// ```
#[macro_export]
+// TODO(stable) needs stable const `mem::uninitialized` OR stable const `MaybeUninit::new()` (RFC
+// 1892)
+#[cfg(feature = "singleton")]
macro_rules! singleton {
(: $ty:ty = $expr:expr) => {
$crate::interrupt::free(|_| {
static mut USED: bool = false;
static mut VAR: $crate::UntaggedOption<$ty> = $crate::UntaggedOption { none: () };
-
#[allow(unsafe_code)]
let used = unsafe { USED };
if used {
@@ -92,6 +94,7 @@ macro_rules! singleton {
/// }
/// ```
#[allow(dead_code)]
+#[cfg(feature = "singleton")]
const CFAIL: () = ();
/// ```
@@ -107,4 +110,5 @@ const CFAIL: () = ();
/// }
/// ```
#[allow(dead_code)]
+#[cfg(feature = "singleton")]
const CPASS: () = ();