Struct rustc_errors::styled_buffer::StyledString
source · [−]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
sourceimpl<T> StyledString<T>where
T: Clone + PartialEq + Eq + Style,
impl<T> StyledString<T>where
T: Clone + PartialEq + Eq + Style,
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>);Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more