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>) -> StyledString<T>
pub fn new(text: String, style: Option<T>) -> StyledString<T>
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 copy 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 Component<DiagnosticStyle> for StyledString<DiagnosticStyle>
impl Component<DiagnosticStyle> for StyledString<DiagnosticStyle>
Source§fn format(
&self,
sb: &mut StyledBuffer<DiagnosticStyle>,
_: &mut Vec<ComponentFormatError>,
)
fn format( &self, sb: &mut StyledBuffer<DiagnosticStyle>, _: &mut Vec<ComponentFormatError>, )
Source§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more