about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2016-04-15 17:53:43 +0200
committerTobias Bucher <tobiasbucher5991@gmail.com>2016-04-15 17:53:43 +0200
commit3df35a01e9825bbdebb986f980095e468357975f (patch)
treead26d419fc07de2c3f8c29ba211b8693ec3c0d1e /src/libstd
parentbf5da36f1dfae45941ec39ef67a41fdbd22c1a50 (diff)
downloadrust-3df35a01e9825bbdebb986f980095e468357975f.tar.gz
rust-3df35a01e9825bbdebb986f980095e468357975f.zip
Implement `Default` for more types in the standard library
Also add `Hash` to `std::cmp::Ordering` and most possible traits to
`fmt::Error`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sync/condvar.rs7
-rw-r--r--src/libstd/sync/mutex.rs7
-rw-r--r--src/libstd/sync/rwlock.rs7
3 files changed, 21 insertions, 0 deletions
diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs
index 64468be396f..57932f03796 100644
--- a/src/libstd/sync/condvar.rs
+++ b/src/libstd/sync/condvar.rs
@@ -220,6 +220,13 @@ impl Condvar {
     pub fn notify_all(&self) { unsafe { self.inner.inner.notify_all() } }
 }
 
+#[stable(feature = "condvar_default", since = "1.9.0")]
+impl Default for Condvar {
+    fn default() -> Condvar {
+        Condvar::new()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Drop for Condvar {
     fn drop(&mut self) {
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index e0946a5c12a..857a4cba9c7 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -310,6 +310,13 @@ impl<T: ?Sized> Drop for Mutex<T> {
     }
 }
 
+#[stable(feature = "mutex_default", since = "1.9.0")]
+impl<T: ?Sized + Default> Default for Mutex<T> {
+    fn default() -> Mutex<T> {
+        Mutex::new(Default::default())
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index a37c1c16a45..09b1b0a939d 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -346,6 +346,13 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
     }
 }
 
+#[stable(feature = "rw_lock_default", since = "1.9.0")]
+impl<T: Default> Default for RwLock<T> {
+    fn default() -> RwLock<T> {
+        RwLock::new(Default::default())
+    }
+}
+
 struct Dummy(UnsafeCell<()>);
 unsafe impl Sync for Dummy {}
 static DUMMY: Dummy = Dummy(UnsafeCell::new(()));