2019-01-02 15:48:44 -06:00
|
|
|
// aux-build:option_helpers.rs
|
|
|
|
|
2019-01-02 00:23:00 -06:00
|
|
|
//! Checks implementation of `RESULT_MAP_UNWRAP_OR_ELSE`
|
|
|
|
|
|
|
|
#![warn(clippy::result_map_unwrap_or_else)]
|
|
|
|
|
2019-01-02 15:48:44 -06:00
|
|
|
#[macro_use]
|
|
|
|
extern crate option_helpers;
|
2019-01-02 00:23:00 -06:00
|
|
|
|
|
|
|
fn result_methods() {
|
|
|
|
let res: Result<i32, ()> = Ok(1);
|
|
|
|
|
|
|
|
// Check RESULT_MAP_UNWRAP_OR_ELSE
|
|
|
|
// single line case
|
2019-01-02 01:15:32 -06:00
|
|
|
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
|
|
|
|
// multi line cases
|
|
|
|
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
|
|
|
|
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
|
2019-01-02 00:23:00 -06:00
|
|
|
// macro case
|
|
|
|
let _ = opt_map!(res, |x| x + 1).unwrap_or_else(|e| 0); // should not lint
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|