pub struct FloatingPointRange {
pub min: f64,
pub max: f64,
pub step: f64,
}Expand description
Floating point range constraints for parameters
Fields§
§min: f64Minimum allowed value (inclusive)
max: f64Maximum allowed value (inclusive)
step: f64Step size for value changes (0 = any step allowed)
Implementations§
Source§impl FloatingPointRange
impl FloatingPointRange
Sourcepub const fn new(min: f64, max: f64, step: f64) -> FloatingPointRange
pub const fn new(min: f64, max: f64, step: f64) -> FloatingPointRange
Create a new floating point range
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
A range is well-formed when min <= max and step >= 0 (0 = no step).
Upstream refuses to DECLARE with an ill-formed range
(DeclarationError::InvalidRange); a negative step here would also go
on the wire as a huge u64 in DescribeParameters (issue 1150).
Sourcepub fn contains(&self, value: f64) -> bool
pub fn contains(&self, value: f64) -> bool
Check if a value is within this range.
Issue 1150: step is ENFORCED, mirroring rclrs range.rs. A value is
in range iff min <= v <= max and, when step != 0, v lies on the
lattice min + k*step within floating tolerance. Either endpoint is
always accepted, exactly as upstream (the upper bound need not be on
the lattice). The tolerance is upstream’s: 100 ULP, relative to the
magnitude of the two operands.
Trait Implementations§
Source§impl Clone for FloatingPointRange
impl Clone for FloatingPointRange
Source§fn clone(&self) -> FloatingPointRange
fn clone(&self) -> FloatingPointRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more