File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ macro_rules! __lazy_static_internal {
132132 }
133133 impl $crate:: LazyStatic for $N {
134134 fn initialize( lazy: & Self ) {
135- let _ = & * lazy;
135+ let _ = & * * lazy;
136136 }
137137 }
138138 __lazy_static_internal!( $( $t) * ) ;
Original file line number Diff line number Diff line change @@ -127,3 +127,23 @@ lazy_static! {
127127fn item_name_shadowing ( ) {
128128 assert_eq ! ( * ITEM_NAME_TEST , X ) ;
129129}
130+
131+ use std:: sync:: atomic:: AtomicBool ;
132+ use std:: sync:: atomic:: ATOMIC_BOOL_INIT ;
133+ use std:: sync:: atomic:: Ordering :: SeqCst ;
134+
135+ static PRE_INIT_FLAG : AtomicBool = ATOMIC_BOOL_INIT ;
136+
137+ lazy_static ! {
138+ static ref PRE_INIT : ( ) = {
139+ PRE_INIT_FLAG . store( true , SeqCst ) ;
140+ ( )
141+ } ;
142+ }
143+
144+ #[ test]
145+ fn pre_init ( ) {
146+ assert_eq ! ( PRE_INIT_FLAG . load( SeqCst ) , false ) ;
147+ lazy_static:: initialize ( & PRE_INIT ) ;
148+ assert_eq ! ( PRE_INIT_FLAG . load( SeqCst ) , true ) ;
149+ }
You can’t perform that action at this time.
0 commit comments