2019-10-28 19:00:00 -05:00
|
|
|
// build-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
2015-07-20 07:39:51 -05:00
|
|
|
use std::any::TypeId;
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
type Fp<T> = Rc<T>;
|
|
|
|
|
|
|
|
struct Engine;
|
|
|
|
|
2016-10-06 00:28:27 -05:00
|
|
|
trait Component: 'static {}
|
2015-07-20 07:39:51 -05:00
|
|
|
impl Component for Engine {}
|
|
|
|
|
|
|
|
trait Env {
|
2019-05-28 13:46:13 -05:00
|
|
|
fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<dyn Component>>;
|
2015-07-20 07:39:51 -05:00
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
impl<'a> dyn Env + 'a {
|
2015-07-20 07:39:51 -05:00
|
|
|
fn get_component<T: Component>(&self) -> Option<Fp<T>> {
|
|
|
|
let x = self.get_component_type_id(TypeId::of::<T>());
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Figment {
|
2019-05-28 13:46:13 -05:00
|
|
|
fn init(&mut self, env: &dyn Env);
|
2015-07-20 07:39:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MyFigment;
|
|
|
|
|
|
|
|
impl Figment for MyFigment {
|
2019-05-28 13:46:13 -05:00
|
|
|
fn init(&mut self, env: &dyn Env) {
|
2015-07-20 07:39:51 -05:00
|
|
|
let engine = env.get_component::<Engine>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|