Skip to content
Snippets Groups Projects
Commit 8e550432 authored by Gino Valente's avatar Gino Valente
Browse files

Updated code to use resolve_or(_else)

parent e01b1603
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ use crate::{ ...@@ -2,7 +2,7 @@ use crate::{
color::Color, color::Color,
layout_cache::Rect, layout_cache::Rect,
render_command::RenderCommand, render_command::RenderCommand,
styles::{Corner, Edge, Style, StyleProp}, styles::{Corner, Edge, Style},
}; };
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
...@@ -56,35 +56,17 @@ impl From<&Style> for RenderPrimitive { ...@@ -56,35 +56,17 @@ impl From<&Style> for RenderPrimitive {
fn from(style: &Style) -> Self { fn from(style: &Style) -> Self {
let render_command = style.render_command.resolve(); let render_command = style.render_command.resolve();
let background_color = if matches!(style.background_color, StyleProp::Default) { let background_color = style.background_color.resolve_or(Color::TRANSPARENT);
Color::TRANSPARENT
} else {
style.background_color.resolve()
};
let border_color = if matches!(style.border_color, StyleProp::Default) { let border_color = style.border_color.resolve_or(Color::TRANSPARENT);
Color::TRANSPARENT
} else {
style.border_color.resolve()
};
let font = if matches!(style.font, StyleProp::Default) { let font = style
String::from(crate::DEFAULT_FONT) .font
} else { .resolve_or_else(|| String::from(crate::DEFAULT_FONT));
style.font.resolve()
};
let font_size = if matches!(style.font_size, StyleProp::Default) { let font_size = style.font_size.resolve_or(14.0);
14.0
} else {
style.font_size.resolve()
};
let line_height = if matches!(style.line_height, StyleProp::Default) { let line_height = style.line_height.resolve_or(font_size * 1.2);
font_size * 1.2
} else {
style.line_height.resolve()
};
match render_command { match render_command {
RenderCommand::Empty => Self::Empty, RenderCommand::Empty => Self::Empty,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment