pub struct StyledString<T>where
    T: Clone + PartialEq + Eq + Style,
{ pub text: String, pub style: Option<T>, }
Expand description

An acceptable custom XXXStyle for StyledString must implement trait Clone, PartialEq, Eq and Style.

Fields

text: Stringstyle: Option<T>

Implementations

Constructs a new StyledString by string and style.

Examples
// You need to choose a style for the generic parameter `T` of `StyledString`.
#[derive(Clone, PartialEq, Eq)]
enum MyStyle{
    Style_1
}
impl Style for MyStyle {
    ...
}
 
let styled_string = StyledString::<MyStyle>::new("Hello Styled String".to_string(), Some<MyStyle::Style_1>);

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.