Struct erg_common::style::StyledString
source · pub struct StyledString { /* private fields */ }
Expand description
StyledString
is for coloring and attribute text.
String, Color(&str) and Attribute(&str)
Implementations§
source§impl StyledString
impl StyledString
sourcepub fn new<'a, S: Into<Cow<'a, str>>>(
s: S,
color: Option<Color>,
attribute: Option<Attribute>
) -> Self
pub fn new<'a, S: Into<Cow<'a, str>>>(
s: S,
color: Option<Color>,
attribute: Option<Attribute>
) -> Self
Example
let s = String::from("Hello, world");
StyledString::new(s, None, None);
let s = "Hello, world";
StyledString::new(s, None, None);
sourcepub fn push_str(&mut self, s: &str)
pub fn push_str(&mut self, s: &str)
Methods for pushing additional &str for strings that already have attributes or colors.
Example
let mut text = StyledString::new("sample text", None, Some(Attribute::Underline));
text.push_str("\n");
text.push_str("Next break line text");
println!("{text}"); // Two lines of text underlined are displayed