]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/sync/poison.rs
std: Relax Result::unwrap() to Debug
[rust.git] / src / libstd / sync / poison.rs
index c97fcf7cefb74a68fb1ef9069377f3b4b3509376..d7fcee3ae2e527df7229c1c2a11a6ad7900f9700 100644 (file)
@@ -53,7 +53,6 @@ pub struct Guard {
 /// is held. The precise semantics for when a lock is poisoned is documented on
 /// each lock, but once a lock is poisoned then all future acquisitions will
 /// return this error.
-#[derive(Show)]
 #[stable]
 pub struct PoisonError<T> {
     guard: T,
@@ -61,7 +60,6 @@ pub struct PoisonError<T> {
 
 /// An enumeration of possible errors which can occur while calling the
 /// `try_lock` method.
-#[derive(Show)]
 #[stable]
 pub enum TryLockError<T> {
     /// The lock could not be acquired because another task failed while holding
@@ -92,6 +90,13 @@ pub enum TryLockError<T> {
 #[stable]
 pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>;
 
+#[stable]
+impl<T> fmt::Debug for PoisonError<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        "PoisonError { inner: .. }".fmt(f)
+    }
+}
+
 #[stable]
 impl<T> fmt::Display for PoisonError<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -133,6 +138,16 @@ fn from_error(err: PoisonError<T>) -> TryLockError<T> {
     }
 }
 
+#[stable]
+impl<T> fmt::Debug for TryLockError<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match *self {
+            TryLockError::Poisoned(..) => "Poisoned(..)".fmt(f),
+            TryLockError::WouldBlock => "WouldBlock".fmt(f)
+        }
+    }
+}
+
 #[stable]
 impl<T> fmt::Display for TryLockError<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {