mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-24 09:06:09 +00:00
Check that scalar is finite on construction
This commit is contained in:
parent
00e38b0068
commit
3a75c9ef92
@ -24,7 +24,12 @@ impl Scalar {
|
||||
|
||||
/// Construct a `Scalar` from an `f64`
|
||||
pub fn from_f64(scalar: f64) -> Self {
|
||||
if scalar.is_finite() {
|
||||
// `scalar` is neither infinite, nor NaN
|
||||
Self(scalar)
|
||||
} else {
|
||||
panic!("Invalid scalar value: {scalar}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a `Scalar` from a `u64`
|
||||
|
Loading…
Reference in New Issue
Block a user