]> git.lizzy.rs Git - rust.git/blob - tests/ui/ok_if_let.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / ok_if_let.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(if_let_some_result)]
5
6 fn str_to_int(x: &str) -> i32 {
7     if let Some(y) = x.parse().ok() { 
8     //~^ERROR Matching on `Some` with `ok()` is redundant
9         y
10     } else {
11         0
12     }
13 }
14
15 fn str_to_int_ok(x: &str) -> i32 {
16     if let Ok(y) = x.parse() {
17         y
18     } else {
19         0
20     }
21 }
22
23 fn main() {
24     let y = str_to_int("1");
25     let z = str_to_int_ok("2");
26     println!("{}{}", y, z);
27 }