From 9d2d69b4f43ee2a0bd6ac3f9cffb9ad13c03618b Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Tue, 17 Jan 2017 14:46:39 -0800 Subject: [PATCH] Simplify Never impls: return the inner uninhabited type for fns taking &self. --- src/util.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/util.rs b/src/util.rs index 7525c9b..534a4eb 100644 --- a/src/util.rs +++ b/src/util.rs @@ -17,21 +17,19 @@ pub struct Never(!); impl fmt::Debug for Never { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { - unreachable!("Never cannot be instantiated"); + self.0 } } impl Error for Never { fn description(&self) -> &str { - match self.0 { - } + self.0 } } impl fmt::Display for Never { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { - match self.0 { - } + self.0 } } @@ -40,8 +38,7 @@ impl Future for Never { type Error = Never; fn poll(&mut self) -> Poll { - match self.0 { - } + self.0 } } @@ -50,8 +47,7 @@ impl Stream for Never { type Error = Never; fn poll(&mut self) -> Poll, Self::Error> { - match self.0 { - } + self.0 } } @@ -59,8 +55,7 @@ impl Serialize for Never { fn serialize(&self, _: &mut S) -> Result<(), S::Error> where S: Serializer { - match self.0 { - } + self.0 } }