mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
38d4ac7cea
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
23 lines
710 B
Rust
23 lines
710 B
Rust
// aux-build:option_helpers.rs
|
|
|
|
//! Checks implementation of `RESULT_MAP_UNWRAP_OR_ELSE`
|
|
|
|
#![warn(clippy::result_map_unwrap_or_else)]
|
|
|
|
#[macro_use]
|
|
extern crate option_helpers;
|
|
|
|
fn result_methods() {
|
|
let res: Result<i32, ()> = Ok(1);
|
|
|
|
// Check RESULT_MAP_UNWRAP_OR_ELSE
|
|
// single line case
|
|
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);
|
|
// macro case
|
|
let _ = opt_map!(res, |x| x + 1).unwrap_or_else(|e| 0); // should not lint
|
|
}
|
|
|
|
fn main() {}
|