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.
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)]
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 {