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