Commit beaef7d
authored
fix compile bug with panic!
```bash
Compiling playground v0.0.1 (/playground)
warning: panic message is not a string literal
--> src/main.rs:48:32
|
48 | Err(why) => panic!(match why {
| ________________________________^
49 | | MathError::NonPositiveLogarithm
50 | | => "logarithm of non-positive number",
51 | | MathError::DivisionByZero
... |
54 | | => "square root of negative number",
55 | | }),
| |_____________^
|
= note: `#[warn(non_fmt_panic)]` on by default
= note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
|
48 | Err(why) => panic!("{}", match why {
| ^^^^^
help: or use std::panic::panic_any instead
|
48 | Err(why) => std::panic::panic_any(match why {
| ^^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 1.46s
Running `target/debug/playground`
thread 'main' panicked at 'square root of negative number', src/main.rs:48:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```1 parent 29d91f5 commit beaef7d
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments