File tree 2 files changed +16
-24
lines changed
2 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 1
1
#![ warn( clippy:: single_option_map) ]
2
2
3
+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
4
+
5
+ static MAYBE_ATOMIC : Option < AtomicUsize > = Some ( AtomicUsize :: new ( 42 ) ) ;
6
+
3
7
fn h ( arg : Option < u32 > ) -> Option < u32 > {
4
8
arg. map ( |x| x * 2 )
5
9
}
@@ -8,10 +12,22 @@ fn j(arg: Option<u64>) -> Option<u64> {
8
12
arg. map ( |x| x * 2 )
9
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 ( ) {
12
27
let answer = Some ( 42u32 ) ;
13
28
let h_result = h ( answer) ;
14
29
15
30
let answer = Some ( 42u64 ) ;
16
31
let j_result = j ( answer) ;
32
+ maps_static_option ( ) ;
17
33
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments