Declaring a bounded parameter currently requires building a ParameterRange struct by hand:
node.declare_parameter("speed")
.default(0.5)
.range(ParameterRange { lower: Some(0.0), upper: Some(1.0), step: None })
.mandatory()?;
Most parameters have no step, so this is a lot of ceremony for a simple bound. Changing the builder to accept impl Into<T::Range> and adding a few conversion impl between Rust range types and ParameterRange would allow native Rust range syntax:
node.declare_parameter("speed").default(0.5).range(0.0..=1.0).mandatory()?;
node.declare_parameter("count").default(5).range(0..10).mandatory()?;
node.declare_parameter("offset").default(-3).range(..=0).mandatory()?;
We would need to add From impls into ParameterRange<T> for:
RangeInclusive<T>, RangeFrom<T>, RangeToInclusive<T>, RangeFull, generic over T: ParameterVariant + PartialOrd
Range<i64> and RangeTo<i64>, converting the exclusive end into the inclusive bound end - 1
Range<f64> and RangeTo<f64> should not be implemented. ParameterRange::upper is inclusive and no floating point value sits just below an exclusive bound, so .range(0.0..1.0) should remain a compile error rather than silently becoming an inclusive bound.
Declaring a bounded parameter currently requires building a
ParameterRangestruct by hand:Most parameters have no step, so this is a lot of ceremony for a simple bound. Changing the builder to accept
impl Into<T::Range>and adding a few conversion impl between Rust range types andParameterRangewould allow native Rust range syntax:We would need to add
Fromimpls intoParameterRange<T>for:RangeInclusive<T>,RangeFrom<T>,RangeToInclusive<T>,RangeFull, generic overT: ParameterVariant + PartialOrdRange<i64>andRangeTo<i64>, converting the exclusive end into the inclusive bound end - 1Range<f64>andRangeTo<f64>should not be implemented.ParameterRange::upperis inclusive and no floating point value sits just below an exclusive bound, so.range(0.0..1.0)should remain a compile error rather than silently becoming an inclusive bound.