1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// waiting for reply there https://github.com/alexcrichton/futures-rs/pull/233
#![allow(deprecated)]

use std::cell::RefCell;

use futures::task::TaskRc;


#[allow(dead_code)]
pub struct TaskRcMut<A>(TaskRc<RefCell<A>>);

impl<A> Clone for TaskRcMut<A> {
    fn clone(&self) -> Self {
        TaskRcMut(self.0.clone())
    }
}

#[allow(dead_code)]
impl<A> TaskRcMut<A> {

    pub fn new(a: A) -> TaskRcMut<A> {
        TaskRcMut(TaskRc::new(RefCell::new(a)))
    }

    pub fn with<F, R>(&self, f: F) -> R
        where F: FnOnce(&mut A) -> R
    {
        self.0.with(|d| f(&mut *d.borrow_mut()))
    }

}