[−][src]Struct text_style::StyledString
An owned string with an optional style annotation.
Example
let s = format!("Some number: {}", 42); let s0 = text_style::StyledString::plain(s.clone()).bold(); let s1 = text_style::StyledString::styled(s.clone(), text_style::Style::fg(text_style::AnsiColor::Red.dark())); let s2 = text_style::StyledString::plain(s.clone()).with(text_style::AnsiColor::Red.dark()); assert_eq!(s1, s2);
Fields
s: String
The content of this string.
style: Option<Style>
The style of this string.
Implementations
impl StyledString
[src]
pub fn new(s: String, style: Option<Style>) -> StyledString
[src]
Creates a new styled string from the given string and an optional style.
pub fn styled(s: String, style: Style) -> StyledString
[src]
Creates a new styled string from the given string and style.
pub fn plain(s: String) -> StyledString
[src]
Creates a new styled string from the given string and style.
pub fn with(self, fg: Color) -> Self
[src]
Sets the foreground color for this styled string.
pub fn on(self, bg: Color) -> Self
[src]
Sets the background color for this styled string.
pub fn bold(self) -> Self
[src]
Sets the bold effect for this styled string.
pub fn italic(self) -> Self
[src]
Sets the italic effect for this styled string.
pub fn underline(self) -> Self
[src]
Sets the underline effect for this styled string.
pub fn effect(self, effect: Effect) -> Self
[src]
Sets the given effect for this styled string.
pub fn style_mut(&mut self) -> &mut Style
[src]
Returns a mutable reference to the style of this string, creating a new style with the
default settings if the style is currently None
.
Trait Implementations
impl Clone for StyledString
[src]
fn clone(&self) -> StyledString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for StyledString
[src]
impl Default for StyledString
[src]
fn default() -> StyledString
[src]
impl<'a> From<&'a StyledString> for StyledStr<'a>
[src]
fn from(s: &'a StyledString) -> StyledStr<'a>
[src]
impl<'a> From<StyledStr<'a>> for StyledString
[src]
fn from(s: StyledStr<'a>) -> StyledString
[src]
impl<'a> From<StyledString> for ANSIString<'a>
[src]
fn from(s: StyledString) -> ANSIString<'a>
[src]
impl From<StyledString> for StyledContent<String>
[src]
fn from(s: StyledString) -> StyledContent<String>
[src]
impl From<StyledString> for StyledString
[src]
fn from(s: StyledString) -> StyledString
[src]
impl PartialEq<StyledString> for StyledString
[src]
fn eq(&self, other: &StyledString) -> bool
[src]
fn ne(&self, other: &StyledString) -> bool
[src]
impl StructuralPartialEq for StyledString
[src]
impl Termion for StyledString
[src]
fn termion(&self) -> TermionStr<'_>
[src]
Auto Trait Implementations
impl RefUnwindSafe for StyledString
impl Send for StyledString
impl Sync for StyledString
impl Unpin for StyledString
impl UnwindSafe for StyledString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.