1
Fork 0

Remove unsafe and Rc

This commit is contained in:
Celina G. Val 2023-10-23 14:21:24 -07:00
parent f613b26cfb
commit 421631a3a1
3 changed files with 15 additions and 22 deletions

View file

@ -243,15 +243,12 @@ pub trait Context {
// datastructures and stable MIR datastructures
scoped_thread_local! (static TLV: Cell<*const ()>);
pub fn run(context: impl Context, f: impl FnOnce()) {
pub fn run(context: &dyn Context, f: impl FnOnce()) {
assert!(!TLV.is_set());
fn g<'a>(context: &(dyn Context + 'a), f: impl FnOnce()) {
let ptr: *const () = &context as *const &_ as _;
TLV.set(&Cell::new(ptr), || {
f();
});
}
g(&context, f);
let ptr: *const () = &context as *const &_ as _;
TLV.set(&Cell::new(ptr), || {
f();
});
}
/// Loads the current context and calls a function with it.