impl Debug for Atomic types

This commit is contained in:
arthurprs 2015-07-19 13:11:30 -03:00
parent a27fed7cbd
commit 225ad17520

View File

@ -78,6 +78,7 @@ use intrinsics;
use cell::UnsafeCell;
use default::Default;
use fmt;
/// A boolean type which can be safely shared between threads.
#[stable(feature = "rust1", since = "1.0.0")]
@ -1089,3 +1090,23 @@ pub fn fence(order: Ordering) {
}
}
}
macro_rules! impl_Debug {
($($t:ident)*) => ($(
#[stable(feature = "atomic_debug", since = "1.3.0")]
impl fmt::Debug for $t {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple(stringify!($t)).field(&self.load(Ordering::SeqCst)).finish()
}
}
)*);
}
impl_Debug!{ AtomicUsize AtomicIsize AtomicBool }
#[stable(feature = "atomic_debug", since = "1.3.0")]
impl<T> fmt::Debug for AtomicPtr<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("AtomicPtr").field(&self.load(Ordering::SeqCst)).finish()
}
}