Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Replace mt_lazy_static with MtSticky
Browse files Browse the repository at this point in the history
`LinkedList` was stabilized in 1.39.0, so it can now be constructed in a
constant context.
  • Loading branch information
yvt committed Nov 7, 2019
1 parent b7f2e07 commit 7e29034
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tcw3/pal/src/testing/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ use std::{
};

use super::Wm;
use crate::{prelude::*, MtLock};
use crate::{MtLock, MtSticky};

mt_lazy_static! {
static <Wm> ref UNSEND_DISPATCHES: RefCell<LinkedList<Box<dyn FnOnce(Wm)>>> =>
|_| RefCell::new(LinkedList::new());
}
static UNSEND_DISPATCHES: MtSticky<RefCell<LinkedList<Box<dyn FnOnce(Wm)>>>> = {
// This is safe because the created value does not contain an actual
// unsendable content (`Box<dyn FnOnce(Wm)>`) yet
unsafe { MtSticky::new_unchecked(RefCell::new(LinkedList::new())) }
};

static DISPATCH_RECV: MtLock<RefCell<Option<Receiver<Dispatch>>>> = MtLock::new(RefCell::new(None));

Expand Down

0 comments on commit 7e29034

Please sign in to comment.