I have the following definitions:
trait A {
fn f(&self);
}
trait B: A {
// ...
}
I'd like implement this kind of function:
fn convert(v: Rc<RefCell<dyn B>>) -> Rc<RefCell<dyn A>> {
}
I'd like to have a way for returning a value that share the same object, that's means that with these declarations:
let x: Rc<RefCell<dyn B>> /* = ... */;
let y = convert(Rc::clone(&x));
The calls x.f()
and y.f()
apply the call on the same object.
How can i implement the function convert
or how can change the type definitions to have that behaviour and that kind of conversion (a conversion to a sub-object).
Thank for your ideas, i decided to use a compromise by avoiding the use of a trait-object as parameter of the function
convert
in according to Rust rules:Playground