@@ -25,7 +25,7 @@ pub enum Singleton {
25
25
Production ( Container ! [ Send + Sync ] ) ,
26
26
27
27
#[ cfg( debug_assertions) ]
28
- Testing ( std :: sync :: Mutex < std:: collections:: HashMap < String , Container ! [ Send + Sync ] > > ) ,
28
+ Testing ( parking_lot :: Mutex < std:: collections:: HashMap < String , Container ! [ Send + Sync ] > > ) ,
29
29
}
30
30
31
31
unsafe impl Send for Singleton { }
@@ -45,7 +45,7 @@ impl Singleton {
45
45
Some ( name) => name,
46
46
None => panic ! ( "thread doesn't have name" ) ,
47
47
} ;
48
- let guard = c. lock ( ) . expect ( "lock must succeed" ) ;
48
+ let guard = c. lock ( ) ;
49
49
let v: & T = guard
50
50
. get ( thread_name)
51
51
. expect ( "thread {name} is not initiated" )
@@ -65,7 +65,7 @@ impl Singleton {
65
65
Some ( name) => name,
66
66
None => panic ! ( "thread doesn't have name" ) ,
67
67
} ;
68
- let mut guard = c. lock ( ) . expect ( "lock must succeed" ) ;
68
+ let mut guard = c. lock ( ) ;
69
69
let c = guard. entry ( thread_name. to_string ( ) ) . or_default ( ) ;
70
70
c. set ( value)
71
71
}
@@ -104,7 +104,7 @@ impl GlobalInstance {
104
104
/// Should only be initiated once and only used in testing.
105
105
#[ cfg( debug_assertions) ]
106
106
pub fn init_testing ( ) {
107
- let _ = GLOBAL . set ( Singleton :: Testing ( std :: sync :: Mutex :: default ( ) ) ) ;
107
+ let _ = GLOBAL . set ( Singleton :: Testing ( parking_lot :: Mutex :: default ( ) ) ) ;
108
108
}
109
109
110
110
/// drop testing global data by thread name.
@@ -117,7 +117,7 @@ impl GlobalInstance {
117
117
unreachable ! ( "drop_testing should never be called on production global" )
118
118
}
119
119
Singleton :: Testing ( c) => {
120
- let mut guard = c. lock ( ) . expect ( "lock must succeed" ) ;
120
+ let mut guard = c. lock ( ) ;
121
121
let _ = guard. remove ( thread_name) ;
122
122
}
123
123
}
0 commit comments