2018-10-06 11:18:06 -05:00
|
|
|
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
|
2018-10-11 05:16:22 -05:00
|
|
|
|
2016-10-29 11:56:12 -05:00
|
|
|
|
2017-09-18 05:47:33 -05:00
|
|
|
|
2018-07-28 10:34:52 -05:00
|
|
|
#![warn(clippy::all)]
|
2018-10-10 10:13:53 -05:00
|
|
|
#![warn(clippy::redundant_pattern_matching)]
|
2016-10-29 11:56:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if let Ok(_) = Ok::<i32, i32>(42) {}
|
2017-02-08 07:58:07 -06:00
|
|
|
|
2016-10-29 11:56:12 -05:00
|
|
|
if let Err(_) = Err::<i32, i32>(42) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if let None = None::<()> {
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(_) = Some(42) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if Ok::<i32, i32>(42).is_ok() {
|
|
|
|
}
|
|
|
|
|
|
|
|
if Err::<i32, i32>(42).is_err() {
|
|
|
|
}
|
|
|
|
|
|
|
|
if None::<i32>.is_none() {
|
|
|
|
}
|
|
|
|
|
|
|
|
if Some(42).is_some() {
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Ok(x) = Ok::<i32,i32>(42) {
|
|
|
|
println!("{}", x);
|
|
|
|
}
|
2018-10-07 08:36:42 -05:00
|
|
|
|
|
|
|
match Ok::<i32, i32>(42) {
|
|
|
|
Ok(_) => true,
|
|
|
|
Err(_) => false,
|
|
|
|
};
|
|
|
|
|
|
|
|
match Ok::<i32, i32>(42) {
|
|
|
|
Ok(_) => false,
|
|
|
|
Err(_) => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
match Err::<i32, i32>(42) {
|
|
|
|
Ok(_) => false,
|
|
|
|
Err(_) => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
match Err::<i32, i32>(42) {
|
|
|
|
Ok(_) => true,
|
|
|
|
Err(_) => false,
|
|
|
|
};
|
|
|
|
|
|
|
|
match Some(42) {
|
|
|
|
Some(_) => true,
|
|
|
|
None => false,
|
|
|
|
};
|
|
|
|
|
|
|
|
match None::<()> {
|
|
|
|
Some(_) => false,
|
|
|
|
None => true,
|
|
|
|
};
|
2016-10-29 11:56:12 -05:00
|
|
|
}
|