We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dbebd48 commit b0de53cCopy full SHA for b0de53c
2 files changed
tests/ui/single_option_map.rs
@@ -1,5 +1,9 @@
1
#![warn(clippy::single_option_map)]
2
3
+use std::sync::atomic::{AtomicUsize, Ordering};
4
+
5
+static MAYBE_ATOMIC: Option<AtomicUsize> = Some(AtomicUsize::new(42));
6
7
fn h(arg: Option<u32>) -> Option<u32> {
8
arg.map(|x| x * 2)
9
}
@@ -8,10 +12,22 @@ fn j(arg: Option<u64>) -> Option<u64> {
12
13
10
14
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
11
26
fn main() {
27
let answer = Some(42u32);
28
let h_result = h(answer);
29
30
let answer = Some(42u64);
31
let j_result = j(answer);
32
+ maps_static_option();
33
tests/ui/single_option_map.stderr
0 commit comments