aboutsummaryrefslogtreecommitdiffstats
path: root/src/fnnop.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-06 17:52:16 -0400
committerBrian Cully <bjc@kublai.com>2019-08-06 17:52:35 -0400
commitd213bba502043aac09a0bdb845278a53ea04f600 (patch)
treea6ba6c1e46e56af1fd557c6476f01ef8321ef1d8 /src/fnnop.rs
parent392239c7f522acb7ca5847a48dd9ab2480242924 (diff)
downloadclint-stable-support.tar.gz
clint-stable-support.zip
WIP: stalled out trying to implement const-fn feature.stable-support
Unfortunately, to maintain API compatibility, `replace` needs to be a regular borrow, so we need interior mutability with `UnsafeCell`. Simultaneously, `HandlerArray` needs to be `const fn` so it can be used where `lazy_static` isn't available, which means it needs to initialize its array in one go without the help of `MaybeUninit`. To do that, `Handler` must be `Copy`, but since it contains an `UnsafeCell` now, it cannot be copy. And thus we are boned. There are times when I think the premise of rust is admirable, but implementation is impossible.
Diffstat (limited to 'src/fnnop.rs')
-rw-r--r--src/fnnop.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fnnop.rs b/src/fnnop.rs
index 871a6ab..13b9379 100644
--- a/src/fnnop.rs
+++ b/src/fnnop.rs
@@ -2,6 +2,7 @@
//
//#![feature(unboxed_closures)]
//#![feature(fn_traits)]
+use core::cell::UnsafeCell;
pub struct FnNOP();
@@ -16,4 +17,4 @@ impl FnOnce<()> for FnNOP {
extern "rust-call" fn call_once(self, _args: ()) {}
}
-static mut NOP: FnNOP = FnNOP();
+pub static mut NOP: UnsafeCell<FnNOP> = UnsafeCell::new(FnNOP());