mirror of
https://github.com/rm-dr/daisy
synced 2025-07-01 14:43:30 -07:00
Added wasm implementations for formattedtext
This commit is contained in:
33
src/formattedtext/formattedtext.rs
Normal file
33
src/formattedtext/formattedtext.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use std::ops::Add;
|
||||
|
||||
|
||||
#[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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user