about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-04-15 20:26:19 -0700
committerbors <bors@rust-lang.org>2016-04-15 20:26:19 -0700
commit6fa61b810dc95ca3e8bbda1681229f855f214fc4 (patch)
treeb8adce9739d902adb0c0a62ed9f2918cae502412 /src/libcore
parentfef6c64a8020c357dda902593f1065864564c079 (diff)
parent3df35a01e9825bbdebb986f980095e468357975f (diff)
downloadrust-6fa61b810dc95ca3e8bbda1681229f855f214fc4.tar.gz
rust-6fa61b810dc95ca3e8bbda1681229f855f214fc4.zip
Auto merge of #32785 - tbu-:pr_more_defaults, r=alexcrichton
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/libcore')
-rw-r--r--src/libcore/cell.rs7
-rw-r--r--src/libcore/cmp.rs2
-rw-r--r--src/libcore/fmt/mod.rs2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index a1c7a293af0..257027dad5e 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -859,3 +859,10 @@ impl<T: ?Sized> UnsafeCell<T> {
         &self.value as *const T as *mut T
     }
 }
+
+#[stable(feature = "unsafe_cell_default", since = "1.9.0")]
+impl<T: Default> Default for UnsafeCell<T> {
+    fn default() -> UnsafeCell<T> {
+        UnsafeCell::new(Default::default())
+    }
+}
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index 49aa0238a99..d3481ba3f05 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -128,7 +128,7 @@ pub trait Eq: PartialEq<Self> {
 /// let result = 2.cmp(&1);
 /// assert_eq!(Ordering::Greater, result);
 /// ```
-#[derive(Clone, Copy, PartialEq, Debug)]
+#[derive(Clone, Copy, PartialEq, Debug, Hash)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub enum Ordering {
     /// An ordering where a compared value is less [than another].
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 2f02f5c21f5..0c824b5a8e6 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -60,7 +60,7 @@ pub type Result = result::Result<(), Error>;
 /// occurred. Any extra information must be arranged to be transmitted through
 /// some other means.
 #[stable(feature = "rust1", since = "1.0.0")]
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
 pub struct Error;
 
 /// A collection of methods that are required to format a message into a stream.