上級 › E0004: non-exhaustive patterns の原因と直し方 › パターン5
E0004: non-exhaustive patterns の原因と直し方
match式は、値が取りうるすべてのパターンを網羅していなければコンパイルできません。
1 enum Role { Admin, Editor, Viewer } 2 fn main() { 3 let r = Role::Editor; 4 let perm = match r { 5 Role::Admin => "full", 6 ________________________________________________________ ^ 7 }; 8 println!("{}", perm); 9 }
error[E0004]: non-exhaustive patterns: `Role::Viewer` not covered
空欄を埋めて実行を通す
network-exhaustiveのチェックのおかげで、新しいバリアントの対応漏れをコンパイル時に発見できます。
次の問題