// check-pass
use std::marker::PhantomData;
struct Meta {
value: i32,
type_: PhantomData
}
trait MetaTrait {
fn get_value(&self) -> i32;
}
impl MetaTrait for Meta {
fn get_value(&self) -> i32 { self.value }
}
trait Bar {
fn get_const(&self) -> &dyn MetaTrait;
}
struct Foo {
_value: A
}
impl Foo {
const CONST: &'static dyn MetaTrait = &Meta:: {
value: 10,
type_: PhantomData
};
}
impl Bar for Foo {
fn get_const(&self) -> &dyn MetaTrait { Self::CONST }
}
fn main() {
let foo = Foo:: { _value: 10 };
let bar: &dyn Bar = &foo;
println!("const {}", bar.get_const().get_value());
}