docs

#E0121: 无效的 cfg 谓词

#[cfg(..)] 或 cfg!(..) 的谓词格式不对。谓词是一个标志(unix)、一个 key = "value" 对,或者由它们组成的 all(..)、any(..) 和 not(..)。

nabi
#[cfg(either(target_family = "unix", target_family = "windows"))]
println("desktop");
error[E0121]: unknown cfg combinator `either` (`all`, `any`, `not`)
  --> main.nabi:1:1
   |
 1 | #[cfg(either(target_family = "unix", target_family = "windows"))]
   | ^^

使用 all、any 或 not:

nabi
#[cfg(any(target_family = "unix", target_family = "windows"))]
println("desktop");
desktop

第 17 章列出了所有的键。

相关错误码:E0109 格式错误的属性

发现错误? 在 GitHub 上编辑此页 最后更新: