@@ -68,7 +68,7 @@ use std::cell::RefCell;
6868use std:: collections:: HashMap ;
6969use std:: fmt;
7070use std:: hash:: { BuildHasherDefault , Hasher } ;
71- use std:: rc :: Rc ;
71+ use std:: sync :: Arc ;
7272
7373pub mod propagation;
7474
@@ -80,7 +80,7 @@ thread_local! {
8080/// An execution-scoped collection of values.
8181#[ derive( Clone , Default ) ]
8282pub struct Context {
83- entries : HashMap < TypeId , Rc < dyn Any > , BuildHasherDefault < IdHasher > > ,
83+ entries : HashMap < TypeId , Arc < dyn Any + Sync + Send > , BuildHasherDefault < IdHasher > > ,
8484}
8585
8686impl Context {
@@ -141,11 +141,11 @@ impl Context {
141141 /// assert_eq!(all_current_and_b.get::<ValueA>(), Some(&ValueA("a")));
142142 /// assert_eq!(all_current_and_b.get::<ValueB>(), Some(&ValueB(42)));
143143 /// ```
144- pub fn current_with_value < T : ' static > ( value : T ) -> Self {
144+ pub fn current_with_value < T : ' static + Send + Sync > ( value : T ) -> Self {
145145 let mut new_context = Context :: current ( ) ;
146146 new_context
147147 . entries
148- . insert ( TypeId :: of :: < T > ( ) , Rc :: new ( value) ) ;
148+ . insert ( TypeId :: of :: < T > ( ) , Arc :: new ( value) ) ;
149149
150150 new_context
151151 }
@@ -204,11 +204,11 @@ impl Context {
204204 /// assert_eq!(cx_with_a_and_b.get::<ValueA>(), Some(&ValueA("a")));
205205 /// assert_eq!(cx_with_a_and_b.get::<ValueB>(), Some(&ValueB(42)));
206206 /// ```
207- pub fn with_value < T : ' static > ( & self , value : T ) -> Self {
207+ pub fn with_value < T : ' static + Send + Sync > ( & self , value : T ) -> Self {
208208 let mut new_context = self . clone ( ) ;
209209 new_context
210210 . entries
211- . insert ( TypeId :: of :: < T > ( ) , Rc :: new ( value) ) ;
211+ . insert ( TypeId :: of :: < T > ( ) , Arc :: new ( value) ) ;
212212
213213 new_context
214214 }
0 commit comments