about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-04-17 17:50:34 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-04-17 17:50:34 +0530
commit5fc8065ef269d1d4e4d8fe4134dcd17c5b9407fb (patch)
tree19bfe5504cb7b1704d7ec6d0699ec9eec460fff7 /src/libcore
parent51c3c430cd40f64110f5e0f91182fe78404aeab0 (diff)
parent79e68a61a90fc6631e22a1d81d275c6e658d4771 (diff)
downloadrust-5fc8065ef269d1d4e4d8fe4134dcd17c5b9407fb.tar.gz
rust-5fc8065ef269d1d4e4d8fe4134dcd17c5b9407fb.zip
Rollup merge of #33023 - tbu-:pr_wrapping_traits, r=alexcrichton
Implement `Display` and `Hash` for `std::num::Wrapping`

Also, change the `Debug` implementation to only show the inner value.

Fixes #33006.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/num/mod.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index f0bbe9672ab..589ac90b308 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -38,9 +38,23 @@ use slice::SliceExt;
 /// all standard arithmetic operations on the underlying value are
 /// intended to have wrapping semantics.
 #[stable(feature = "rust1", since = "1.0.0")]
-#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Default)]
+#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
 pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
 
+#[stable(feature = "rust1", since = "1.0.0")]
+impl<T: fmt::Debug> fmt::Debug for Wrapping<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
+#[stable(feature = "wrapping_display", since = "1.10.0")]
+impl<T: fmt::Display> fmt::Display for Wrapping<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
 mod wrapping;
 
 // All these modules are technically private and only exposed for libcoretest: