Skip to content

Commit dc114ee

Browse files
author
Yusuf Raji
committed
Test scenarios that shouldn't be linted
1 parent 4df6872 commit dc114ee

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

tests/ui/single_option_map.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#![warn(clippy::single_option_map)]
22

3+
use std::sync::atomic::{AtomicUsize, Ordering};
4+
5+
static MAYBE_ATOMIC: Option<AtomicUsize> = Some(AtomicUsize::new(42));
6+
37
fn h(arg: Option<u32>) -> Option<u32> {
48
arg.map(|x| x * 2)
59
}
@@ -8,10 +12,22 @@ fn j(arg: Option<u64>) -> Option<u64> {
812
arg.map(|x| x * 2)
913
}
1014

15+
fn maps_static_option() -> Option<usize> {
16+
MAYBE_ATOMIC.as_ref().map(|a| a.load(Ordering::Relaxed))
17+
}
18+
19+
fn manipulate(i: i32) -> i32 {
20+
i + 1
21+
}
22+
fn manipulate_opt(opt_i: Option<i32>) -> Option<i32> {
23+
opt_i.map(manipulate)
24+
}
25+
1126
fn main() {
1227
let answer = Some(42u32);
1328
let h_result = h(answer);
1429

1530
let answer = Some(42u64);
1631
let j_result = j(answer);
32+
maps_static_option();
1733
}

tests/ui/single_option_map.stderr

-24
This file was deleted.

0 commit comments

Comments
 (0)