Janitor: Replace float comparison dance with approx_eq from euclid

Sixtyfps uses euclid already, so let's use euclid for float comparisons
as well.

I changed the code to decide whether a number is a positive integer to
make do without a comparison along the way.
This commit is contained in:
Tobias Hunger 2021-07-22 20:01:23 +02:00
parent e45635656d
commit 02bdcbf6ff
6 changed files with 11 additions and 11 deletions

View file

@ -14,6 +14,7 @@ mod lsp_ext;
mod preview;
mod util;
use euclid::approxeq::ApproxEq;
use std::collections::HashMap;
use structopt::StructOpt;
@ -271,7 +272,7 @@ fn handle_request(
// representation.
let requested_color = params.color;
let color_literal = if (requested_color.alpha - 1.).abs() > 10.0 * f32::EPSILON {
let color_literal = if requested_color.alpha.approx_eq(&1.) {
format!(
"#{:0>2x}{:0>2x}{:0>2x}{:0>2x}",
(requested_color.red * 255.) as u8,