How to coerce the generic type of a `Rc` inside another `Rc`?
The Rust Programming Language Forum
How to coerce the generic type of a `Rc` inside another `Rc`?
Here is the usage. I want to have a DataSource<dyn Trait> instead of the origin type, but as operator does not work here. Unsafe code is allowed, but I still have no idea. The trait is provided externally, that is to say I don't know what trait the user will coerce to. How can I implement this coercion? Thanks. use std::cell::RefCell; use std::rc::Rc; pub struct DataSource<T: ?Sized> { current: RefCell<Rc<T>>, } impl<T: ?Sized> DataSource<T> { pub fn new(init: Rc<T>) -> Rc<Self> { ...
Here is the usage. I want to have a DataSource<dyn Trait> instead of the origin type, but as operator does not work here. Unsafe code is allowed, but I still have no idea. The…
0 comments
No comments yet.