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
pub fn is_empty(&self) -> bool
Trait Implementations§
source§impl Clone for StyledString
impl Clone for StyledString
source§fn clone(&self) -> StyledString
fn clone(&self) -> StyledString
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StyledString
impl Debug for StyledString
source§impl Display for StyledString
impl Display for StyledString
source§impl From<StyledStr<'_>> for StyledString
impl From<StyledStr<'_>> for StyledString
source§impl Hash for StyledString
impl Hash for StyledString
source§impl PartialEq<StyledString> for StyledString
impl PartialEq<StyledString> for StyledString
source§fn eq(&self, other: &StyledString) -> bool
fn eq(&self, other: &StyledString) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.