pub struct StyledString<T>{
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: String§style: Option<T>Implementations§
Source§impl<T> StyledString<T>
impl<T> StyledString<T>
Sourcepub fn new(text: String, style: Option<T>) -> Self
pub fn new(text: String, style: Option<T>) -> Self
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>);Trait Implementations§
Source§impl<T> Clone for StyledString<T>
impl<T> Clone for StyledString<T>
Source§fn clone(&self) -> StyledString<T>
fn clone(&self) -> StyledString<T>
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<T> Debug for StyledString<T>
impl<T> Debug for StyledString<T>
Source§impl<T> PartialEq for StyledString<T>
impl<T> PartialEq for StyledString<T>
impl<T> Eq for StyledString<T>
impl<T> StructuralPartialEq for StyledString<T>
Auto Trait Implementations§
impl<T> Freeze for StyledString<T>where
T: Freeze,
impl<T> RefUnwindSafe for StyledString<T>where
T: RefUnwindSafe,
impl<T> Send for StyledString<T>where
T: Send,
impl<T> Sync for StyledString<T>where
T: Sync,
impl<T> Unpin for StyledString<T>where
T: Unpin,
impl<T> UnwindSafe for StyledString<T>where
T: UnwindSafe,
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