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 for StyledString
impl PartialEq for StyledString
impl Eq for StyledString
impl StructuralPartialEq for StyledString
Auto Trait Implementations§
impl Freeze for StyledString
impl RefUnwindSafe for StyledString
impl Send for StyledString
impl Sync for StyledString
impl Unpin for StyledString
impl UnwindSafe for StyledString
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)