Use combinators instead of manual code

macos-click-through
Michael Doronin 3 years ago committed by Keith Simmons
parent 2a0f464f34
commit 2689bccbb9

@ -66,25 +66,19 @@ impl Cursor {
} }
pub fn foreground(&self, default_colors: &Colors) -> Color4f { pub fn foreground(&self, default_colors: &Colors) -> Color4f {
if let Some(style) = &self.style { self
style .style
.colors .as_ref()
.foreground .and_then(|s| s.colors.foreground)
.unwrap_or_else(|| default_colors.background.unwrap()) .unwrap_or(default_colors.background.unwrap())
} else {
default_colors.background.unwrap()
}
} }
pub fn background(&self, default_colors: &Colors) -> Color4f { pub fn background(&self, default_colors: &Colors) -> Color4f {
if let Some(style) = &self.style { self
style .style
.colors .as_ref()
.background .and_then(|s| s.colors.background)
.unwrap_or_else(|| default_colors.foreground.unwrap()) .unwrap_or(default_colors.foreground.unwrap())
} else {
default_colors.foreground.unwrap()
}
} }
pub fn change_mode(&mut self, cursor_mode: &CursorMode, styles: &HashMap<u64, Arc<Style>>) { pub fn change_mode(&mut self, cursor_mode: &CursorMode, styles: &HashMap<u64, Arc<Style>>) {

Loading…
Cancel
Save