use std::marker::PhantomData;
struct Dog<T: Hello> {
_mark: PhantomData<T>
}
impl<T: Hello> Dog<T> {
fn new() -> Dog<T> {
T::hello();
Dog {
_mark: PhantomData
}
}
fn hello(&self) {
T::hello();
}
}
trait Hello: Sized {
fn hello() {
println!("hello");
}
fn query() -> Dog<Self> {
Dog::new()
}
}
fn main() {
struct Cat {}
impl Hello for Cat {}
let dog = Cat::query();
dog.hello();
}