chris-morgan / mopa

MOPA: My Own Personal Any. A macro to implement all the `Any` methods on your own trait.
Other
112 stars 9 forks source link

Downcast an owned boxed value? #8

Closed mdg closed 7 years ago

mdg commented 7 years ago

Is it possible to downcast an owned boxed value instead of a ref?

Something like:

let p: Box<Person> = person_alice;
let alice: Option<Box<Alice>> = Mopa.downcast_box::<Alice>(p);
chris-morgan commented 7 years ago

p.downcast::<Alice>() will get you an Result<Box<Alice>, Box<Person>>.