all: use trait upcasting
This commit is contained in:
parent
f0caafc862
commit
09e5f89174
44 changed files with 90 additions and 269 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{it::test_error::TestError, object::Object},
|
||||
std::rc::Rc,
|
||||
std::{any::Any, rc::Rc},
|
||||
};
|
||||
|
||||
pub trait TestObjectExt {
|
||||
|
|
@ -9,7 +9,7 @@ pub trait TestObjectExt {
|
|||
|
||||
impl TestObjectExt for dyn Object {
|
||||
fn downcast<T: 'static>(self: Rc<Self>) -> Result<Rc<T>, TestError> {
|
||||
match self.into_any().downcast() {
|
||||
match (self as Rc<dyn Any>).downcast() {
|
||||
Ok(t) => Ok(t),
|
||||
_ => bail!("Object has an incompatible type id"),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue