From 583fb0e9c915fb60adbf367411ff8258497e68e1 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 28 Mar 2022 08:42:33 -0400 Subject: [PATCH] assert default values --- Cargo.toml | 1 + src/consts.rs | 5 +++++ src/lib.rs | 3 +++ src/main.rs | 3 +++ 4 files changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 610cb27..4cdd01a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ ruzstd = { git = "https://github.com/KillingSpark/zstd-rs.git" } serde_json = "1.0.79" tracing = "0.1.32" itertools = "0.10.3" +static_assertions = "1.1.0" [build-dependencies] shadow-rs = "0.11.0" diff --git a/src/consts.rs b/src/consts.rs index 27dd1ac..10e5a20 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -24,6 +24,9 @@ pub const INTEGRAL_X_MIN: f64 = -1000.0; /// Maximum X value for calculating an Integral pub const INTEGRAL_X_MAX: f64 = 1000.0; + +const_assert!(INTEGRAL_X_MAX > INTEGRAL_X_MIN); + /// Range of acceptable x coordinates for calculating an integral pub const INTEGRAL_X_RANGE: RangeInclusive = INTEGRAL_X_MIN..=INTEGRAL_X_MAX; @@ -39,5 +42,7 @@ pub const DEFAULT_MIN_X: f64 = -10.0; pub const DEFAULT_MAX_X: f64 = 10.0; +const_assert!(DEFAULT_MAX_X > DEFAULT_MIN_X); + /// Default number of integral boxes pub const DEFAULT_INTEGRAL_NUM: usize = 100; diff --git a/src/lib.rs b/src/lib.rs index 32b1f1f..e19d942 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,9 @@ #![allow(clippy::unused_unit)] // Fixes clippy keep complaining about wasm_bindgen #![feature(const_mut_refs)] +#[macro_use] +extern crate static_assertions; + mod consts; mod egui_app; mod function; diff --git a/src/main.rs b/src/main.rs index 1098dd9..0940271 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ #![feature(const_mut_refs)] +#[macro_use] +extern crate static_assertions; + mod consts; mod egui_app; mod function;