Struct text_style::StyledStr[][src]

pub struct StyledStr<'a> {
    pub s: &'a str,
    pub style: Option<Style>,
}
Expand description

A borrowed string with an optional style annotation.

Example

let s = text_style::StyledStr::plain("test").bold();

let s1 = text_style::StyledStr::styled("test", text_style::Style::fg(text_style::AnsiColor::Red.dark()));
let s2 = text_style::StyledStr::plain("test").with(text_style::AnsiColor::Red.dark());
assert_eq!(s1, s2);

Fields

s: &'a str

The content of this string.

style: Option<Style>

The style of this string.

Implementations

Creates a new styled string from the given string and an optional style.

Creates a new styled string from the given string and style.

Creates a new styled string from the given string without a style.

Sets the foreground color for this styled string.

Sets the background color for this styled string.

Sets the bold effect for this styled string.

Sets the italic effect for this styled string.

Sets the underline effect for this styled string.

Sets the strikethrough effect for this styled string.

Sets the given effect for this styled string.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Convert this string into a TermionStr that can be formatted with termion. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Calls the given closure and return the result. Read more

Calls the given closure on self.

Calls the given closure on self.

Calls the given closure if condition == true.