mirror of
https://github.com/rm-dr/daisy
synced 2025-06-30 22:23:40 -07:00
40 lines
699 B
Rust
40 lines
699 B
Rust
use std::ops::Add;
|
|
use std::ops::AddAssign;
|
|
|
|
|
|
#[derive(Debug)]
|
|
#[derive(Clone)]
|
|
pub struct FormattedText {
|
|
pub(super) text: String
|
|
}
|
|
|
|
impl ToString for FormattedText {
|
|
fn to_string(&self) -> String { return self.text.clone(); }
|
|
}
|
|
|
|
impl FormattedText {
|
|
pub fn new(s: String) -> FormattedText {
|
|
return FormattedText {
|
|
text: s
|
|
}
|
|
}
|
|
|
|
pub fn push(&mut self, s: &str) {
|
|
self.text.push_str(s);
|
|
}
|
|
}
|
|
|
|
|
|
impl Add for FormattedText {
|
|
type Output = Self;
|
|
|
|
fn add(self, other: Self) -> Self::Output {
|
|
return FormattedText::new(format!("{}{}", self.text, other.text));
|
|
}
|
|
}
|
|
|
|
impl AddAssign for FormattedText where {
|
|
fn add_assign(&mut self, other: Self) {
|
|
self.text.push_str(&other.text);
|
|
}
|
|
} |