docs

#E0016: 放在沒有意義之處的可見性

pub 寫在不會改變任何事情的地方:區塊內的函式或項目(它只在該區塊中可見),或列舉變體(變體沿用列舉的可見性)。請刪除它。

nabi
enum Color { pub Red, Blue }
error[E0016]: enum variants take the enum's visibility; remove the visibility keyword
  --> main.nabi:1:14
   |
 1 | enum Color { pub Red, Blue }
   |              ^^^

刪除變體上的 pub;要讓變體可見,請把列舉標為 pub。

nabi
#[derive(Debug)]
pub enum Color { Red, Blue }
println(f"{Color::Red:?}");
Red

相關錯誤碼:E0034 項目是私有的

發現錯誤? 在 GitHub 上編輯此頁 最後更新: