Skip to content

Commit

Permalink
feat: add Display requirement on generic types of Styled
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelmello committed Aug 19, 2021
1 parent 7b4bf0f commit 5d51f28
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ui/style.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Contains definitions to apply style to rendered contents.
use std::fmt::Display;

use bitflags::bitflags;

use super::Color;
Expand Down Expand Up @@ -125,20 +127,22 @@ impl Default for StyleSheet {

/// Represents a content that when rendered must have the associated style
/// applied to it.
///
/// The struct does not require that `T` implements [Display], however
/// the only mapped use for this struct, printing in on [Terminal] requires
/// `T` to implement it.
#[derive(Clone, Debug)]
pub struct Styled<T> {
pub struct Styled<T>
where
T: Display,
{
/// Content to be rendered.
pub content: T,

/// Style sheet to be applied to content when rendered.
pub style: StyleSheet,
}

impl<T> Styled<T> {
impl<T> Styled<T>
where
T: Display,
{
/// Creates a new `Styled` object with the specified content
/// and a default (empty) style sheet.
pub fn new(content: T) -> Self {
Expand Down

0 comments on commit 5d51f28

Please sign in to comment.