Skip to content

Commit

Permalink
rollup merge of rust-lang#18344 : aochagavia/show-arc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 27, 2014
2 parents 1cc938a + 79e05e9 commit cfeff3e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use core::atomic;
use core::clone::Clone;
use core::fmt::{mod, Show};
use core::kinds::{Sync, Send};
use core::mem::{min_align_of, size_of, drop};
use core::mem;
Expand Down Expand Up @@ -147,6 +148,12 @@ impl<T: Send + Sync> Deref<T> for Arc<T> {
}
}

impl<T: Send + Sync + Show> Show for Arc<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
}
}

impl<T: Send + Sync + Clone> Arc<T> {
/// Acquires a mutable pointer to the inner contents by guaranteeing that
/// the reference count is one (no sharing is possible).
Expand Down Expand Up @@ -280,6 +287,7 @@ mod tests {
use std::mem::drop;
use std::ops::Drop;
use std::option::{Option, Some, None};
use std::str::Str;
use std::sync::atomic;
use std::task;
use std::vec::Vec;
Expand Down Expand Up @@ -426,4 +434,10 @@ mod tests {
assert!(canary.load(atomic::Acquire) == 1);
drop(arc_weak);
}

#[test]
fn show_arc() {
let a = Arc::new(5u32);
assert!(format!("{}", a).as_slice() == "5")
}
}

0 comments on commit cfeff3e

Please sign in to comment.