about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-04-10 19:23:22 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-04-10 19:26:06 +0200
commitf1515fabb027e901a5cb47826f12ba89db2df078 (patch)
treee7ab11b538b1aac3898a8b6ac6ea35ddd7850a87 /src/libcore
parentacb3e5136c3ca0a0d27150136fa7ffecbee75b92 (diff)
downloadrust-f1515fabb027e901a5cb47826f12ba89db2df078.tar.gz
rust-f1515fabb027e901a5cb47826f12ba89db2df078.zip
Add Default trait for AtomicBool, AtomicIsize and AtomicUsize
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/atomic.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs
index ed35e095492..02f9ee506f9 100644
--- a/src/libcore/atomic.rs
+++ b/src/libcore/atomic.rs
@@ -78,12 +78,20 @@ use intrinsics;
 use cell::UnsafeCell;
 use marker::PhantomData;
 
+use default::Default;
+
 /// A boolean type which can be safely shared between threads.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct AtomicBool {
     v: UnsafeCell<usize>,
 }
 
+impl Default for AtomicBool {
+    fn default() -> AtomicBool {
+        ATOMIC_BOOL_INIT
+    }
+}
+
 unsafe impl Sync for AtomicBool {}
 
 /// A signed integer type which can be safely shared between threads.
@@ -92,6 +100,12 @@ pub struct AtomicIsize {
     v: UnsafeCell<isize>,
 }
 
+impl Default for AtomicIsize {
+    fn default() -> AtomicIsize {
+        ATOMIC_ISIZE_INIT
+    }
+}
+
 unsafe impl Sync for AtomicIsize {}
 
 /// An unsigned integer type which can be safely shared between threads.
@@ -100,6 +114,12 @@ pub struct AtomicUsize {
     v: UnsafeCell<usize>,
 }
 
+impl Default for AtomicUsize {
+    fn default() -> AtomicUsize {
+        ATOMIC_USIZE_INIT
+    }
+}
+
 unsafe impl Sync for AtomicUsize {}
 
 /// A raw pointer type which can be safely shared between threads.