chiark / gitweb /
Oh wait I don't need to _implement_ Eq
authorSimon Tatham <anakin@pobox.com>
Sun, 24 Dec 2023 21:01:13 +0000 (21:01 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 24 Dec 2023 21:01:13 +0000 (21:01 +0000)
src/coloured_string.rs

index 9f4ae851d51e10e3b5035ba8ec951a0c974b7626..9d21ec83fe8ed4be3744109cd39dd45ccef1dbdc 100644 (file)
@@ -1,13 +1,13 @@
 use unicode_width::UnicodeWidthStr;
 use unicode_width::UnicodeWidthChar;
 
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
 pub struct ColouredString {
     text: String,
     colour: String,
 }
 
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
 pub struct ColouredStringSlice<'a> {
     text: &'a str,
     colour: &'a str,
@@ -70,22 +70,6 @@ impl<'a> ColouredStringSlice<'a> {
     pub fn text(&self) -> &'a str { &self.text }
 }
 
-impl PartialEq for ColouredString {
-    fn eq(&self, rhs: &Self) -> bool {
-        self.text == rhs.text && self.colour == rhs.colour
-    }
-}
-
-impl Eq for ColouredString {}
-
-impl<'a> PartialEq for ColouredStringSlice<'a> {
-    fn eq(&self, rhs: &ColouredStringSlice) -> bool {
-        self.text == rhs.text && self.colour == rhs.colour
-    }
-}
-
-impl<'a> Eq for ColouredStringSlice<'a> {}
-
 impl std::ops::Add<ColouredString> for ColouredString {
     type Output = Self;
     fn add(self, rhs: Self) -> Self {