dit*_*lav 5 reference lifetime rust borrow-checker borrowing
warning: hidden lifetime parameters in types are deprecated
--> asd/src/app/qwe.rs:88:45
|
88 | fn add_meta_from_args(&mut self, args: &ArgMatches) -> AppRun {
| ^^^^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
Run Code Online (Sandbox Code Playgroud)
我应该在哪里指定这个匿名生命周期?我也不太明白它的必要性。如果参数是借用的,为什么它也需要生命周期?
ArgMatches<'a>其中的结构在clap生命周期内是通用的。您还没有写出args函数中的完整类型,因为您省略了结构的生命周期参数ArgMatches,这就是编译器抱怨类型参数是“隐藏”的原因,并建议您args通过写入ArgMatches<'_>来提供完整类型使您的代码更加明确和清晰。
| 归档时间: |
|
| 查看次数: |
4287 次 |
| 最近记录: |