From ee2d40d77f6ac3a7f6e72163d484f2801e4922fe Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 26 Aug 2019 04:07:52 +0200 Subject: Make `Color` optional instead of `Default` --- src/widget/text.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/widget/text.rs') diff --git a/src/widget/text.rs b/src/widget/text.rs index bf5c1624..018c7cc5 100644 --- a/src/widget/text.rs +++ b/src/widget/text.rs @@ -27,16 +27,13 @@ use std::hash::Hash; pub struct Text { content: String, size: u16, - color: Color, + color: Option, style: Style, horizontal_alignment: HorizontalAlignment, vertical_alignment: VerticalAlignment, } -impl Text -where - Color: Default, -{ +impl Text { /// Create a new fragment of [`Text`] with the given contents. /// /// [`Text`]: struct.Text.html @@ -44,7 +41,7 @@ where Text { content: String::from(label), size: 20, - color: Color::default(), + color: None, style: Style::default().fill_width(), horizontal_alignment: HorizontalAlignment::Left, vertical_alignment: VerticalAlignment::Top, @@ -64,7 +61,7 @@ where /// [`Text`]: struct.Text.html /// [`Color`]: ../../../graphics/struct.Color.html pub fn color(mut self, color: Color) -> Self { - self.color = color; + self.color = Some(color); self } @@ -180,7 +177,7 @@ pub trait Renderer { bounds: Rectangle, content: &str, size: f32, - color: Color, + color: Option, horizontal_alignment: HorizontalAlignment, vertical_alignment: VerticalAlignment, ); -- cgit