我收到这个编译器错误,我不理解也不知道如何修复:
error[E0277]: the trait bound `&'a mut Runnable + 'a: Runnable` is not satisfied
--> src/main.rs:11:9
|
11 | &mut self.runnables[id]
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Runnable` is not implemented for `&'a mut Runnable + 'a`
|
= note: required for the cast to the object type `Runnable + 'a`
我已将代码简化为:
pub trait Runnable {
fn name(&self) -> &str;
}
pub struct RunList<'a> {
runnables: Vec<&'a mut Runnable>,
}
impl<'a> RunList<'a> {
pub fn get(&self, id: usize) -> &'a mut Runnable {
&mut self.runnables[id]
}
}
fn main() {}