}
}
+ pub fn to_owned(&self) -> ColouredString {
+ ColouredString {
+ text: self.text.to_string(),
+ colour: self.colour.to_string(),
+ }
+ }
+
pub fn nchars(&self) -> usize { self.text.chars().count() }
pub fn width(&self) -> usize { UnicodeWidthStr::width(&self.text as &str) }
pub fn text(&self) -> &'a str { &self.text }
}
}
+impl std::ops::Add<&ColouredString> for ColouredString {
+ type Output = Self;
+ fn add(self, rhs: &ColouredString) -> Self {
+ ColouredString {
+ text: self.text + &rhs.text,
+ colour: self.colour + &rhs.colour,
+ }
+ }
+}
+
impl std::ops::Add<&str> for ColouredString {
type Output = Self;
fn add(self, rhs: &str) -> Self {
}
}
+impl std::ops::Add<ColouredString> for &ColouredString {
+ type Output = ColouredString;
+ fn add(self, rhs: ColouredString) -> ColouredString {
+ ColouredString {
+ text: self.text.to_string() + &rhs.text,
+ colour: self.colour.to_string() + &rhs.colour,
+ }
+ }
+}
+
impl std::ops::Add<ColouredString> for &str {
type Output = ColouredString;
fn add(self, rhs: ColouredString) -> ColouredString {