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 15
15
16
16
use core:: atomic;
17
17
use core:: clone:: Clone ;
18
+ use core:: fmt:: { mod, Show } ;
18
19
use core:: kinds:: { Sync , Send } ;
19
20
use core:: mem:: { min_align_of, size_of, drop} ;
20
21
use core:: mem;
@@ -147,6 +148,12 @@ impl<T: Send + Sync> Deref<T> for Arc<T> {
147
148
}
148
149
}
149
150
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
+
150
157
impl < T : Send + Sync + Clone > Arc < T > {
151
158
/// Acquires a mutable pointer to the inner contents by guaranteeing that
152
159
/// the reference count is one (no sharing is possible).
@@ -280,6 +287,7 @@ mod tests {
280
287
use std:: mem:: drop;
281
288
use std:: ops:: Drop ;
282
289
use std:: option:: { Option , Some , None } ;
290
+ use std:: str:: Str ;
283
291
use std:: sync:: atomic;
284
292
use std:: task;
285
293
use std:: vec:: Vec ;
@@ -426,4 +434,10 @@ mod tests {
426
434
assert ! ( canary. load( atomic:: Acquire ) == 1 ) ;
427
435
drop ( arc_weak) ;
428
436
}
437
+
438
+ #[ test]
439
+ fn show_arc ( ) {
440
+ let a = Arc :: new ( 5u32 ) ;
441
+ assert ! ( format!( "{}" , a) . as_slice( ) == "5" )
442
+ }
429
443
}
You can’t perform that action at this time.
0 commit comments