pub struct Styled<T>where
T: Display,{
pub content: T,
pub style: StyleSheet,
}
Expand description
Represents a content that when rendered must have the associated style applied to it.
Fields
content: T
Content to be rendered.
style: StyleSheet
Style sheet to be applied to content when rendered.
Implementations
sourceimpl<T> Styled<T>where
T: Display,
impl<T> Styled<T>where
T: Display,
sourcepub fn new(content: T) -> Self
pub fn new(content: T) -> Self
Creates a new Styled
object with the specified content
and a default (empty) style sheet.
sourcepub fn with_style_sheet(self, style_sheet: StyleSheet) -> Self
pub fn with_style_sheet(self, style_sheet: StyleSheet) -> Self
Sets the style sheet to the styled struct.
sourcepub fn with_fg(self, fg: Color) -> Self
pub fn with_fg(self, fg: Color) -> Self
Sets the styled content to have the defined foreground Color.
sourcepub fn with_bg(self, bg: Color) -> Self
pub fn with_bg(self, bg: Color) -> Self
Sets the styled content to have the defined foreground Color.
sourcepub fn with_attr(self, attributes: Attributes) -> Self
pub fn with_attr(self, attributes: Attributes) -> Self
Sets the styled content to have the defined attributes.
Warning: this does not keep the previously applied attributes. If you want to just set a new attribute and keep the others, you need to apply the OR operation yourself.
Trait Implementations
impl<T> Copy for Styled<T>where
T: Copy + Display,
Auto Trait Implementations
impl<T> RefUnwindSafe for Styled<T>where
T: RefUnwindSafe,
impl<T> Send for Styled<T>where
T: Send,
impl<T> Sync for Styled<T>where
T: Sync,
impl<T> Unpin for Styled<T>where
T: Unpin,
impl<T> UnwindSafe for Styled<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