pub struct AnsiString { /* private fields */ }Expand description
A String that contains ANSI state (e.g. colors)
It is internally represented as Vec<(attr, string)>
Implementations§
Source§impl AnsiString
impl AnsiString
pub fn new_empty() -> Self
Sourcepub fn new_string(
stripped: String,
fragments: Vec<(Attr, (usize, usize))>,
) -> Self
pub fn new_string( stripped: String, fragments: Vec<(Attr, (usize, usize))>, ) -> Self
assume the fragments are ordered by (start, end) while end is exclusive
pub fn parse(raw: &str) -> AnsiString
pub fn is_empty(&self) -> bool
pub fn into_inner(self) -> String
pub fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (char, Attr)> + 'a>
pub fn has_attrs(&self) -> bool
pub fn stripped(&self) -> &str
pub fn override_attrs(&mut self, attrs: Vec<(Attr, (usize, usize))>)
Trait Implementations§
Source§impl Clone for AnsiString
impl Clone for AnsiString
Source§fn clone(&self) -> AnsiString
fn clone(&self) -> AnsiString
Returns a duplicate 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 AnsiString
impl Debug for AnsiString
Source§impl<'a> From<DisplayContext<'a>> for AnsiString
impl<'a> From<DisplayContext<'a>> for AnsiString
Source§fn from(context: DisplayContext<'_>) -> Self
fn from(context: DisplayContext<'_>) -> Self
Converts to this type from the input type.
Source§impl From<String> for AnsiString
impl From<String> for AnsiString
Source§fn from(s: String) -> AnsiString
fn from(s: String) -> AnsiString
Converts to this type from the input type.
Source§impl<'a> IntoIterator for &'a AnsiString
impl<'a> IntoIterator for &'a AnsiString
Auto Trait Implementations§
impl Freeze for AnsiString
impl RefUnwindSafe for AnsiString
impl Send for AnsiString
impl Sync for AnsiString
impl Unpin for AnsiString
impl UnwindSafe for AnsiString
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more