mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Janitor: Use approx_eq when checking for integer
Use approx_eq when comparing the value.trunc() to value. We want to allow these values to be calculated, so they might end up slightly off.
This commit is contained in:
parent
f1f0182826
commit
85f7c93c87
1 changed files with 3 additions and 1 deletions
|
@ -9,6 +9,8 @@
|
|||
LICENSE END */
|
||||
//! Passe that compute the layout constraint
|
||||
|
||||
use lyon_path::geom::euclid::approxeq::ApproxEq;
|
||||
|
||||
use crate::diagnostics::BuildDiagnostics;
|
||||
use crate::diagnostics::Spanned;
|
||||
use crate::expression_tree::*;
|
||||
|
@ -502,7 +504,7 @@ fn eval_const_expr(
|
|||
) -> Option<u16> {
|
||||
match expression {
|
||||
Expression::NumberLiteral(v, Unit::None) => {
|
||||
if *v < 0. || *v > u16::MAX as f64 || v.trunc() != *v {
|
||||
if *v < 0. || *v > u16::MAX as f64 || !v.trunc().approx_eq(v) {
|
||||
diag.push_error(format!("'{}' must be a positive integer", name), span);
|
||||
None
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue