error[E0621]: explicit lifetime required in the type of `is`
--> src/bee.rs:76:45
|
75 | fn compute_instruction_set<'a>(is: &'a mut InstructionSet) {
| ---------------------- help: add explicit lifetime `'a` to the type of `is`: `&'a mut [OpCode<'a>; 255]`
76 | let mut isb = InstructionSetBuilder{is: is, pos: 0};
| ^^ lifetime `'a` required
这是代码:
type InstructionSet<'a> = [OpCode<'a>; 0xff];
...
struct InstructionSetBuilder<'a> {
is: &'a mut [OpCode<'a>],
pos: usize,
}
...
fn compute_instruction_set<'a>(is: &'a mut InstructionSet) {
let mut isb = InstructionSetBuilder{is: is, pos: 0};
...
}
为什么我需要设置另一个“一生”参数?
在哪里?
我试了几种组合,都破坏了语法......
1条答案
按热度按时间uttx8gqw1#
此类型别名在生存期
'a
内是泛型的。因此必须指定它。请尝试使用此别名。