【发布时间】:2015-07-15 07:52:03
【问题描述】:
我正在尝试使用具有以闭包作为参数的函数的特征,然后在特征对象上使用它。
trait A {
fn f<P>(&self, p: P) where P: Fn() -> ();
}
struct B {
a: Box<A>
}
impl B {
fn c(&self) {
self.a.f(|| {});
}
}
这个sn-p会产生如下错误:
the trait `A` is not implemented for the type `A` [E0277]
rustc 的版本是rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25)。
【问题讨论】: