Skip to content

Commit cfeff3e

Browse files
committed
rollup merge of rust-lang#18344 : aochagavia/show-arc
2 parents 1cc938a + 79e05e9 commit cfeff3e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/liballoc/arc.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1616
use core::atomic;
1717
use core::clone::Clone;
18+
use core::fmt::{mod, Show};
1819
use core::kinds::{Sync, Send};
1920
use core::mem::{min_align_of, size_of, drop};
2021
use 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+
150157
impl<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
}

0 commit comments

Comments
 (0)