jay-compositor 1.13.0

The Jay compositor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use {
    crate::{it::test_error::TestError, object::Object},
    std::{any::Any, 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 as Rc<dyn Any>).downcast() {
            Ok(t) => Ok(t),
            _ => bail!("Object has an incompatible type id"),
        }
    }
}