karmaio 0.1.0

A modern, fast, share-nothing asynchronous runtime for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::cell::UnsafeCell;

pub trait UnsafeCellExt<T> {
    fn with<R>(&self, f: impl FnOnce(*const T) -> R) -> R;
    fn with_mut<R>(&self, f: impl FnOnce(*mut T) -> R) -> R;
}

impl<T> UnsafeCellExt<T> for UnsafeCell<T> {
    fn with<R>(&self, f: impl FnOnce(*const T) -> R) -> R {
        f(self.get())
    }

    fn with_mut<R>(&self, f: impl FnOnce(*mut T) -> R) -> R {
        f(self.get())
    }
}