diff options
author | Brian Cully <bjc@kublai.com> | 2019-08-06 17:52:16 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-08-06 17:52:35 -0400 |
commit | d213bba502043aac09a0bdb845278a53ea04f600 (patch) | |
tree | a6ba6c1e46e56af1fd557c6476f01ef8321ef1d8 /src/fnnop.rs | |
parent | 392239c7f522acb7ca5847a48dd9ab2480242924 (diff) | |
download | clint-d213bba502043aac09a0bdb845278a53ea04f600.tar.gz clint-d213bba502043aac09a0bdb845278a53ea04f600.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.rs | 3 |
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()); |