1
我尝试以下防锈类型别名:为什么这个Rust类型别名需要一个生命周期参数?
type Name = String;
它工作正常。所以,我想变体:
type Name = &str;
这种失败:
error[E0106]: missing lifetime specifier
--> src/main.rs:1:17
|
1 | type Name = &str;
| ^expected lifetime parameter
为什么一个类型别名需要一辈子的参数,我会怎么加呢?