]> git.lizzy.rs Git - rust.git/commitdiff
std: Switch string::ParseError to an empty enum
authorAlex Crichton <alex@alexcrichton.com>
Thu, 24 Sep 2015 16:40:50 +0000 (09:40 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 24 Sep 2015 16:40:50 +0000 (09:40 -0700)
It can never be instantiated, so signify this by having it actually be an empty
`enum`.

cc #27734

src/libcollections/string.rs

index bb65d7469ab14938ecb7021f7f93ec6a2b9c9e90..eb6aa4eec30e85f5546c2cd84b309a2070ab0de7 100644 (file)
@@ -1030,8 +1030,8 @@ fn deref_mut(&mut self) -> &mut str {
 #[unstable(feature = "str_parse_error", reason = "may want to be replaced with \
                                                   Void if it ever exists",
            issue = "27734")]
-#[derive(Copy, Clone, Debug, Eq, PartialEq)]
-pub struct ParseError(());
+#[derive(Copy)]
+pub enum ParseError {}
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl FromStr for String {
@@ -1042,6 +1042,26 @@ fn from_str(s: &str) -> Result<String, ParseError> {
     }
 }
 
+impl Clone for ParseError {
+    fn clone(&self) -> ParseError {
+        match *self {}
+    }
+}
+
+impl fmt::Debug for ParseError {
+    fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
+        match *self {}
+    }
+}
+
+impl PartialEq for ParseError {
+    fn eq(&self, _: &ParseError) -> bool {
+        match *self {}
+    }
+}
+
+impl Eq for ParseError {}
+
 /// A generic trait for converting a value to a string
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait ToString {