From ee32e7ad1ce26d4eebe601344e0343cfb9c8f9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Barv=C3=AD=C5=99?= Date: Sun, 16 Apr 2023 11:10:35 +0200 Subject: Clippy fixes (#581) --- library/src/text/deco.rs | 6 ++++-- library/src/text/raw.rs | 2 +- library/src/text/shaping.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'library/src/text') diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index ab89e6b5..7b90b22f 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -315,11 +315,13 @@ pub(super) fn decorate( // Only do the costly segments intersection test if the line // intersects the bounding box. - if bbox.map_or(false, |bbox| { + let intersect = bbox.map_or(false, |bbox| { let y_min = -text.font.to_em(bbox.y_max).at(text.size); let y_max = -text.font.to_em(bbox.y_min).at(text.size); offset >= y_min && offset <= y_max - }) { + }); + + if intersect { // Find all intersections of segments with the line. intersections.extend( path.segments() diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index c6fba253..6d90bc5b 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -285,7 +285,7 @@ fn to_syn(RgbaColor { r, g, b, a }: RgbaColor) -> synt::Color { /// The syntect syntax definitions. static SYNTAXES: Lazy = - Lazy::new(|| syntect::parsing::SyntaxSet::load_defaults_nonewlines()); + Lazy::new(syntect::parsing::SyntaxSet::load_defaults_nonewlines); /// The default theme used for syntax highlighting. pub static THEME: Lazy = Lazy::new(|| synt::Theme { diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs index 0e5e0a73..50c4bcbd 100644 --- a/library/src/text/shaping.rs +++ b/library/src/text/shaping.rs @@ -379,7 +379,7 @@ impl<'a> ShapedText<'a> { // RTL needs offset one because the left side of the range should be // exclusive and the right side inclusive, contrary to the normal // behaviour of ranges. - self.glyphs[idx].safe_to_break.then(|| idx + (!ltr) as usize) + self.glyphs[idx].safe_to_break.then_some(idx + usize::from(!ltr)) } } -- cgit v1.2.3