From 904704d7c1b006c850654dcf3bf9e856e23cb317 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 18 Jul 2024 13:14:56 +0200 Subject: Flesh out the `markdown` example a bit more --- core/src/text.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/src/text.rs') diff --git a/core/src/text.rs b/core/src/text.rs index d73eb94a..22cfce13 100644 --- a/core/src/text.rs +++ b/core/src/text.rs @@ -267,12 +267,24 @@ impl<'a, Font> Span<'a, Font> { self } + /// Sets the font of the [`Span`], if any. + pub fn font_maybe(mut self, font: Option>) -> Self { + self.font = font.map(Into::into); + self + } + /// Sets the [`Color`] of the [`Span`]. pub fn color(mut self, color: impl Into) -> Self { self.color = Some(color.into()); self } + /// Sets the [`Color`] of the [`Span`], if any. + pub fn color_maybe(mut self, color: Option>) -> Self { + self.color = color.map(Into::into); + self + } + /// Turns the [`Span`] into a static one. pub fn to_static(self) -> Span<'static, Font> { Span { -- cgit