我正在使用宏生成代码,该宏包含完全合格的类型路径,如下所示:
let vec: Vec::<String>;
请注意::
之前的额外<String>
。这是必要的,以便通过附加::new()
,相同的输入令牌也可以用于构造函数:
Vec::<String>::new()
但是,这会产生警告:
warning: unnecessary path disambiguator
--> src/main.rs:4:17
|
4 | let vec: Vec::<String>;
| ^^ try removing `::`
我无法删除::
,因为这样我会收到错误消息:
error: chained comparison operators require parentheses
--> src/main.rs:6:14
|
6 | vec = Vec<String>::new();
| ^^^^^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments
error[E0423]: expected value, found struct `Vec`
--> src/main.rs:6:11
|
6 | vec = Vec<String>::new();
| ^^^
| |
| did you mean `vec`?
| did you mean `Vec { /* fields */ }`?
如何仅针对这一行禁用警告?