aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs2
-rw-r--r--src/macros.rs19
2 files changed, 4 insertions, 17 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 802a2d5..407c5ac 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,8 +14,6 @@
extern crate aligned;
extern crate bare_metal;
-#[cfg(feature = "singleton")]
-extern crate untagged_option;
extern crate volatile_register;
#[macro_use]
diff --git a/src/macros.rs b/src/macros.rs
index 7af64bc..7bbc9be 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -50,32 +50,23 @@ 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: () };
+ static mut VAR: Option<$ty> = None;
#[allow(unsafe_code)]
- let used = unsafe { USED };
+ let used = unsafe { VAR.is_some() };
if used {
None
} else {
- #[allow(unsafe_code)]
- unsafe { USED = true }
-
let expr = $expr;
#[allow(unsafe_code)]
- unsafe { VAR.some = expr }
+ unsafe { VAR = Some(expr) }
#[allow(unsafe_code)]
- let var: &'static mut _ = unsafe { &mut VAR.some };
-
- Some(var)
+ unsafe { VAR.as_mut() }
}
})
}
@@ -94,7 +85,6 @@ macro_rules! singleton {
/// }
/// ```
#[allow(dead_code)]
-#[cfg(feature = "singleton")]
const CFAIL: () = ();
/// ```
@@ -110,5 +100,4 @@ const CFAIL: () = ();
/// }
/// ```
#[allow(dead_code)]
-#[cfg(feature = "singleton")]
const CPASS: () = ();