macro_rules! to_dyn {
($trait_:path, $was:expr) => { ... };
}Expand description
If you have a Reference<Foo> where Foo implements the Bar trait, you may end up wanting a
Reference<dyn Bar>. To convert it, you would do this:
struct Foo;
impl Foo {
fn foo_func(&self) {}
}
trait Bar {
fn bar_func(&self) {}
}
impl Bar for Foo {}
let ref_foo = static_reference!(Foo, Foo);
ref_foo.borrow().foo_func();
ref_foo.borrow().bar_func();
let ref_dyn_bar = to_dyn!(Bar, ref_foo);
ref_dyn_bar.borrow().bar_func();The documentation shows rrtk::to_dyn and rrtk::reference::to_dyn separately. These are the
same macro exported in two different places. These paths point to the same code in RRTK. Rust’s
scoping rules for macros are a bit odd, but you should be able to use rrtk::to_dyn and
rrtk::reference::to_dyn interchangably.