File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1515
1616use core:: atomic;
1717use core:: clone:: Clone ;
18+ use core:: fmt:: { mod, Show } ;
1819use core:: kinds:: { Sync , Send } ;
1920use core:: mem:: { min_align_of, size_of, drop} ;
2021use core:: mem;
@@ -147,6 +148,12 @@ impl<T: Send + Sync> Deref<T> for Arc<T> {
147148 }
148149}
149150
151+ impl < T : Send + Sync + Show > Show for Arc < T > {
152+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
153+ ( * * self ) . fmt ( f)
154+ }
155+ }
156+
150157impl < T : Send + Sync + Clone > Arc < T > {
151158 /// Acquires a mutable pointer to the inner contents by guaranteeing that
152159 /// the reference count is one (no sharing is possible).
@@ -280,6 +287,7 @@ mod tests {
280287 use std:: mem:: drop;
281288 use std:: ops:: Drop ;
282289 use std:: option:: { Option , Some , None } ;
290+ use std:: str:: Str ;
283291 use std:: sync:: atomic;
284292 use std:: task;
285293 use std:: vec:: Vec ;
@@ -426,4 +434,10 @@ mod tests {
426434 assert ! ( canary. load( atomic:: Acquire ) == 1 ) ;
427435 drop ( arc_weak) ;
428436 }
437+
438+ #[ test]
439+ fn show_arc ( ) {
440+ let a = Arc :: new ( 5u32 ) ;
441+ assert ! ( format!( "{}" , a) . as_slice( ) == "5" )
442+ }
429443}
You can’t perform that action at this time.
0 commit comments