1
0
Fork 0
forked from wry/wry

it: test subsurface positioning

This commit is contained in:
Julian Orth 2022-05-03 18:32:43 +02:00
parent fd027d9a5a
commit cbf539cbcc
17 changed files with 291 additions and 9 deletions

View file

@ -0,0 +1,17 @@
use {
crate::{it::test_error::TestError, object::Object},
std::rc::Rc,
};
pub trait TestObjectExt {
fn downcast<T: 'static>(self: Rc<Self>) -> Result<Rc<T>, TestError>;
}
impl TestObjectExt for dyn Object {
fn downcast<T: 'static>(self: Rc<Self>) -> Result<Rc<T>, TestError> {
match self.into_any().downcast() {
Ok(t) => Ok(t),
_ => bail!("Object has an incompatible type id"),
}
}
}