From 7e29034b5b89768d7c5775604701d8c02c8ada1c Mon Sep 17 00:00:00 2001 From: yvt Date: Thu, 7 Nov 2019 23:58:25 +0900 Subject: [PATCH] Replace `mt_lazy_static` with `MtSticky` `LinkedList` was stabilized in 1.39.0, so it can now be constructed in a constant context. --- tcw3/pal/src/testing/eventloop.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tcw3/pal/src/testing/eventloop.rs b/tcw3/pal/src/testing/eventloop.rs index 07e2c867..5847b64d 100644 --- a/tcw3/pal/src/testing/eventloop.rs +++ b/tcw3/pal/src/testing/eventloop.rs @@ -11,12 +11,13 @@ use std::{ }; use super::Wm; -use crate::{prelude::*, MtLock}; +use crate::{MtLock, MtSticky}; -mt_lazy_static! { - static ref UNSEND_DISPATCHES: RefCell>> => - |_| RefCell::new(LinkedList::new()); -} +static UNSEND_DISPATCHES: MtSticky>>> = { + // This is safe because the created value does not contain an actual + // unsendable content (`Box`) yet + unsafe { MtSticky::new_unchecked(RefCell::new(LinkedList::new())) } +}; static DISPATCH_RECV: MtLock>>> = MtLock::new(RefCell::new(None));