2013-12-27 00:38:28 -05:00
|
|
|
struct Struct {
|
|
|
|
person: &'static str
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Trait<T> {
|
|
|
|
fn f(&self, x: T);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait<&'static str> for Struct {
|
|
|
|
fn f(&self, x: &'static str) {
|
|
|
|
println!("Hello, {}!", x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-28 14:46:13 -04:00
|
|
|
let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
|
2016-04-05 22:56:23 +03:00
|
|
|
//~^ ERROR `Struct: Trait<isize>` is not satisfied
|
2013-12-27 00:38:28 -05:00
|
|
|
s.f(1);
|
|
|
|
}
|