diff options
author | Farid <70100129+Jujumba@users.noreply.github.com> | 2024-05-30 19:27:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 17:27:40 +0000 |
commit | fb6f6d27888eef9f5d1bdec2dada0a9abea72db4 (patch) | |
tree | 23bd2e6fe529b24905c609e466f724982a604f91 | |
parent | 60b4b6c9f086a6f4bc1cc439daf3b64cf73d1ca8 (diff) | |
download | servo-fb6f6d27888eef9f5d1bdec2dada0a9abea72db4.tar.gz servo-fb6f6d27888eef9f5d1bdec2dada0a9abea72db4.zip |
font_template.rs: apply clippy lints (#32391)
Signed-off-by: Jujumba <far77578@gmail.com>
-rw-r--r-- | components/gfx/font_template.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index dbe5458b7b4..6c2999aef66 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -79,9 +79,9 @@ impl FontTemplateDescriptor { // Sanity-check that the distances are within the expected range // (update if implementation of the distance functions is changed). - assert!(stretch_distance >= 0.0 && stretch_distance <= 2000.0); - assert!(style_distance >= 0.0 && style_distance <= 500.0); - assert!(weight_distance >= 0.0 && weight_distance <= 1600.0); + assert!((0.0..=2000.0).contains(&stretch_distance)); + assert!((0.0..=500.0).contains(&style_distance)); + assert!((0.0..=1600.0).contains(&weight_distance)); // Factors used to weight the distances between the available and target font // properties during font-matching. These ensure that we respect the CSS-fonts @@ -95,9 +95,9 @@ impl FontTemplateDescriptor { const STYLE_FACTOR: f32 = 1.0e4; const WEIGHT_FACTOR: f32 = 1.0e0; - return stretch_distance * STRETCH_FACTOR + + stretch_distance * STRETCH_FACTOR + style_distance * STYLE_FACTOR + - weight_distance * WEIGHT_FACTOR; + weight_distance * WEIGHT_FACTOR } fn matches(&self, descriptor_to_match: &FontDescriptor) -> bool { @@ -395,7 +395,7 @@ impl FontMatchDistanceMethod for FontWeight { return (min_weight.to_float() - self.to_float()) + REVERSE_DISTANCE; } // Lighter weights are not as good as bolder ones within [400..500] - return (self.to_float() - max_weight.to_float()) + NOT_WITHIN_CENTRAL_RANGE; + (self.to_float() - max_weight.to_float()) + NOT_WITHIN_CENTRAL_RANGE } fn to_float(&self) -> f32 { @@ -554,7 +554,7 @@ impl FontMatchDistanceMethod for FontStyle { if min_style == FontStyle::ITALIC { return REVERSE + NEGATE - 2.0; } - return REVERSE + NEGATE - 1.0; + REVERSE + NEGATE - 1.0 } fn to_float(&self) -> f32 { |