[][src]Struct text_style::StyledString

pub struct StyledString {
    pub s: String,
    pub style: Option<Style>,
}

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]

impl Debug for StyledString[src]

impl Default for StyledString[src]

impl<'a> From<&'a StyledString> for StyledStr<'a>[src]

impl<'a> From<StyledStr<'a>> for StyledString[src]

impl<'a> From<StyledString> for ANSIString<'a>[src]

impl From<StyledString> for StyledContent<String>[src]

impl From<StyledString> for StyledString[src]

impl PartialEq<StyledString> for StyledString[src]

impl StructuralPartialEq for StyledString[src]

impl Termion for StyledString[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> With for T