#![allow(unused)] #[macro_use] extern crate qdowncast; use std::any::Any; trait Foo: Any {} qdowncastable!(Foo); qdowncast_methods!(Foo); struct FooBar; impl Foo for FooBar {} fn as_foobar<'a>(foo: &'a Foo) -> Option<&'a FooBar> { foo.downcast_ref() }