@@ -9,11 +9,14 @@ tests. `panic!` is closely tied with the `unwrap` method of both
9
9
[ ` Option ` ] [ ounwrap ] and [ ` Result ` ] [ runwrap ] enums. Both implementations call
10
10
` panic! ` when they are set to [ ` None ` ] or [ ` Err ` ] variants.
11
11
12
- This macro is used to inject panic into a Rust thread, causing the thread to
13
- panic entirely. The string built by this macro (using the [ ` format! ` ] syntax
14
- for building the actual message) is printed to ` stderr ` .
15
-
16
- Each thread's panic can be reaped as the [ ` Box ` ] ` < ` [ ` Any ` ] ` > ` type,
12
+ When using ` panic!() ` you can specify a string payload, that is built using
13
+ the [ ` format! ` ] syntax. That payload is used when injecting the panic into
14
+ the calling Rust thread, causing the thread to panic entirely.
15
+
16
+ The default ` std ` panic handling strategy is to print the message payload to
17
+ the ` stderr ` along with the file/line/column information of the ` panic!() `
18
+ call. You can override the panic hook using [ ` std::panic::set_hook() ` ] .
19
+ Inside the hook a panic can be reaped as the [ ` Box ` ] ` < ` [ ` Any ` ] ` > ` type,
17
20
which contains either a ` &str ` or ` String ` for regular ` panic!() ` invocations.
18
21
To panic with a value of another other type, [ ` panic_any ` ] can be used.
19
22
@@ -26,6 +29,7 @@ See also the macro [`compile_error!`], for raising errors during compilation.
26
29
27
30
[ ounwrap ] : Option::unwrap
28
31
[ runwrap ] : Result::unwrap
32
+ [ `std::panic::set_hook()` ] : ../std/panic/fn.set_hook.html
29
33
[ `panic_any` ] : ../std/panic/fn.panic_any.html
30
34
[ `Box` ] : ../std/boxed/struct.Box.html
31
35
[ `Any` ] : crate::any::Any
0 commit comments