<分区>
我正在尝试将特征用作我的结构中的字段:
pub trait Scene {
type Renderer;
fn update(&mut self);
fn render(&mut self, r: &mut Self::Renderer);
}
struct Example {
active_scene: *mut Scene,
}
当我尝试使用它时,出现错误:
error[E0191]: the value of the associated type `Renderer` (from the trait `Scene`) must be specified
--> src/lib.rs:9:24
|
9 | active_scene: *mut Scene,
| ^^^^^ missing associated type `Renderer` value
如何在字段中指定类型?有什么明显的我想念的吗?