Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bug!unreachable!

💡 お知らせ: このドキュメントはAIによって翻訳されています。表現に違和感がある場合は、原文(英語)を参照するか、翻訳にご協力ください。

Flix は、bug!unreachable! という 2 つの特別な「関数」をサポートしています。これらは、プログラム内部の不変条件(Invariant)が破られており、実行を中断すべきであることを示すために使えます。例えば:

match o {
    case Some(x) => ...
    case None    => bug!("The value of `o` cannot be empty.")
}

別の例を挙げます:

match k {
    case n if n == 0 => ...
    case n if n >= 0 => ...
    case n if n <= 0 => ...
    case n           =>  unreachable!()
}

bug!unreachable! の使用は、可能な限り避けるべきです。