macro_rules! real {
($value:expr) => { ... };
}Expand description
Creates a validated real number from an f64 literal.
This macro provides a concise syntax for creating RealNative64StrictFinite
values from floating-point literals. It uses the panicking from_f64
constructor, which is appropriate for compile-time constants and test code where
validity is guaranteed.
§Panics
Panics if the provided value is not finite (NaN, infinity) or is subnormal.
For fallible conversion, use RealScalar::try_from_f64 directly.
§Examples
use num_valid::real;
use std::f64::consts::PI;
let x = real!(3.14159);
let y = real!(PI);
let z = real!(-42.0);
assert!((x.as_ref() - 3.14159).abs() < 1e-10);Using with mathematical constants:
use num_valid::real;
use std::f64::consts::{PI, E, TAU};
let pi = real!(PI);
let e = real!(E);
let tau = real!(TAU);
let circle_area = real!(PI) * real!(25.0); // π * r² with r=5