mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
42 lines
1.5 KiB
Text
42 lines
1.5 KiB
Text
error: used unwrap or expect in a function that returns result or option
|
|
--> $DIR/unwrap_in_result.rs:22:5
|
|
|
|
|
LL | / fn bad_divisible_by_3(i_str: String) -> Result<bool, String> {
|
|
LL | |
|
|
LL | | // checks whether a string represents a number divisible by 3
|
|
LL | | let i = i_str.parse::<i32>().unwrap();
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
= help: unwrap and expect should not be used in a function that returns result or option
|
|
note: potential non-recoverable error(s)
|
|
--> $DIR/unwrap_in_result.rs:25:17
|
|
|
|
|
LL | let i = i_str.parse::<i32>().unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
= note: `-D clippy::unwrap-in-result` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::unwrap_in_result)]`
|
|
|
|
error: used unwrap or expect in a function that returns result or option
|
|
--> $DIR/unwrap_in_result.rs:33:5
|
|
|
|
|
LL | / fn example_option_expect(i_str: String) -> Option<bool> {
|
|
LL | |
|
|
LL | | let i = i_str.parse::<i32>().expect("not a number");
|
|
LL | | if i % 3 == 0 {
|
|
... |
|
|
LL | | None
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
= help: unwrap and expect should not be used in a function that returns result or option
|
|
note: potential non-recoverable error(s)
|
|
--> $DIR/unwrap_in_result.rs:35:17
|
|
|
|
|
LL | let i = i_str.parse::<i32>().expect("not a number");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 2 previous errors
|
|
|