implement self construction

This commit is contained in:
yggverse 2024-10-12 07:10:56 +03:00
parent c499f10320
commit 6aedb21794
3 changed files with 13 additions and 5 deletions

View file

@ -57,7 +57,7 @@ impl Reader {
markup.push_str(Plain::from(line).markup())
*/
buffer.insert(&mut buffer.end_iter(), &Plain::from(line));
buffer.insert(&mut buffer.end_iter(), Plain::from(line).as_str());
}
// Init widget

View file

@ -1,11 +1,19 @@
use gtk::glib::{gformat, GString};
pub struct Plain {
// nothing yet..
line: GString,
}
impl Plain {
pub fn from(line: &str) -> GString {
gformat!("{}\n", line)
// Construct
pub fn from(line: &str) -> Self {
Self {
line: gformat!("{}\n", line),
}
}
// Getters
pub fn as_str(&self) -> &str {
self.line.as_str()
}
}