I have defined these:
struct MyStruct<T> { /* ... */ }
trait MyTrait: Any { /* ... */ }
impl<T> MyTrait for MyStruct<T> { /* ... */ }
Is it possible to downcast Rc<RefCell<MyTrait>>
to Rc<RefCell<MyStruct<T>>>
(in the context of a function generic on T
)?
fn some_fn<T>(h: &HashMap<String, Rc<RefCell<MyTrait>>>, key: &str) -> Rc<RefCell<MyStruct<T>>> {
let x: Rc<RefCell<MyTrait>> = h.get(key).unwrap().clone();
/* what goes here ??? */ (x)
}