To be honest it is not hard to do on a newtyped Cell<Rc<T>>:
use std::cell::Cell;
use std::rc::Rc;
struct CellRc<T>(Cell<Rc<T>>);
impl<T> Clone for CellRc<T> {
fn clone(&self) -> Self {
unsafe {
CellRc(Cell::new((*self.0.as_ptr()).clone()))
}
}
}
impl CellRc {
fn new(t: T) -> Self {
Self(Cell::new(Rc::new(t)))
}
}
fn main() {
let c = CellRc::new(10);
let g = c.clone();
}
or have a free function
pub fn clone_cell_rc<T>(t: &Cell<Rc<T>>) -> Cell<Rc<T>> {
unsafe {
Cell::new((*t.as_ptr()).clone())
}
}
in general we can do
pub fn clone_cell<T: Clone>(t: &Cell<T>) -> Cell<T> {
unsafe {
Cell::new((*t.as_ptr()).clone())
}
}
But we need to justify the unsafe block above.