File tree Expand file tree Collapse file tree 2 files changed +16
-24
lines changed
Expand file tree Collapse file tree 2 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 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+
37fn 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+
1126fn 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}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments