@@ -782,9 +782,9 @@ let (a, b) = get_tuple_of_two_ints();
782
782
This will introduce two new variables, `a` and `b`, bound to the
783
783
content of the tuple.
784
784
785
- You may only use irrevocable patterns—patterns that can never fail to
786
- match—in let bindings, though. Things like literals, which only match
787
- a specific value, are not allowed.
785
+ You may only use irrefutable patterns—patterns that can never fail to
786
+ match—in let bindings. Other types of patterns, such as literals, are
787
+ not allowed.
788
788
789
789
## Loops
790
790
@@ -821,13 +821,29 @@ in a moment.
821
821
## Failure
822
822
823
823
The `fail` keyword causes the current [task](#tasks) to fail. You use
824
- it to indicate unexpected failure, much like you'd use `exit(1)` in a
825
- C program, except that in Rust, it is possible for other tasks to
826
- handle the failure, allowing the program to continue running.
824
+ it to indicate unexpected failure, much like you'd use `abort` in a
825
+ C program or a fatal exception in a C++ program.
827
826
828
- `fail` takes an optional argument, which must have type `str`. Trying
829
- to access a vector out of bounds, or running a pattern match with no
830
- matching clauses, both result in the equivalent of a `fail`.
827
+ There is no way for the current task to resume execution after
828
+ failure; failure is nonrecoverable. It is, however, possible for
829
+ *another* task to handle the failure, allowing the program to continue
830
+ running.
831
+
832
+ `fail` takes an optional argument specifying the reason for the
833
+ failure. It must have type `str`.
834
+
835
+ In addition to the `fail` statement, the following circumstances cause
836
+ task failure:
837
+
838
+ * Accessing an out-of-bounds element of a vector.
839
+
840
+ * Having no clauses match when evaluating an `alt check` expression.
841
+
842
+ * An assertion failure.
843
+
844
+ * Integer division by zero.
845
+
846
+ * Running out of memory.
831
847
832
848
## Assertions
833
849
0 commit comments