chiark / gitweb /
Move some ColouredString methods to the right file.
authorSimon Tatham <anakin@pobox.com>
Fri, 26 Jan 2024 07:26:33 +0000 (07:26 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 26 Jan 2024 07:26:33 +0000 (07:26 +0000)
Just found these lying around in text.rs, apparently because they were
useful for Paragraph. They should go with the rest of the
ColouredString methods! In particular, is_space() ought to go in the
trait shared between ColouredString{,Slice}, so that there only needs
to be one of it.

src/coloured_string.rs
src/text.rs

index e6a8b80ab61a44da4bf990e651d8074b24f0caf4..01221cae8ec673c76bfa30fd212a53c9c733d468 100644 (file)
@@ -60,6 +60,17 @@ pub trait ColouredStringCommon {
     fn recolour(&self, colour: char) -> ColouredString {
         ColouredString::uniform(self.text(), colour)
     }
+
+    fn is_space(&self) -> bool {
+        if let Some(ch) = self.text().chars().next() {
+            ch == ' '
+        } else {
+            false
+        }
+    }
+    fn is_colour(&self, colour: char) -> bool {
+        self.frags().all(|(_, c)| c == colour)
+    }
 }
 
 #[derive(Debug, Clone, PartialEq, Eq)]
index 880c9913574add1768913679544d9b3dc99adf37..7b280331baa682e3f0eddb6b2aea34bd3ef013a3 100644 (file)
@@ -474,30 +474,6 @@ pub struct Paragraph {
     centred: bool,
 }
 
-impl ColouredString {
-    fn is_space(&self) -> bool {
-        if let Some(ch) = self.text().chars().next() {
-            ch == ' '
-        } else {
-            false
-        }
-    }
-
-    fn is_colour(&self, colour: char) -> bool {
-        self.frags().all(|(_, c)| c == colour)
-    }
-}
-
-impl<'a> ColouredStringSlice<'a> {
-    fn is_space(&self) -> bool {
-        if let Some(ch) = self.text().chars().next() {
-            ch == ' '
-        } else {
-            false
-        }
-    }
-}
-
 impl Paragraph {
     pub fn new() -> Self {
         Paragraph {