Repository navigation
feat!: accept standard Rust ranges in ParameterBuilder::range() - #738
Open
superposition wants to merge 1 commit into
Open
superposition wants to merge 1 commit into
superposition wants to merge 1 commit into
Conversation
Accept convertible bounds in ParameterBuilder::range and implement standard Rust range conversions without a step. Handle exclusive integer underflow through the existing invalid-range validation path and retain exclusive float compile errors. Cover numeric boundaries, declaration kinds, generic forwarding, convertible enums, ROS descriptors, and type inference migrations with tests and doctests. BREAKING CHANGE: range arguments now use Into, so untyped defaults need a type annotation and ambiguous explicit into calls should pass the bounds directly. Refs: ros2-rust#675 Assisted-by: Codex:GPT-6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simple bounds currently require a
ParameterRangestruct literal. This change letscallers write
.range(0.0..=1.0),.range(0..10), or.range(..=0)directly.It changes the builder argument to
impl Into<T::Range>and adds the six requestedstandard range conversions. Conversions have no step; explicit stepped ranges remain
available. Exclusive floating-point upper bounds remain unsupported.
Exclusive integer bounds use checked subtraction. Empty or reversed integer ranges,
including an exclusive end of
i64::MIN, produceDeclarationError::InvalidRangewhen declared instead of overflowing or broadening the accepted values.
Closes #675.
Source compatibility
This intentionally changes type inference at the call site:
.range(Default::default())with a typed default such as.range(ParameterRange::<i64>::default())..range(bounds.into())with.range(bounds)when the intermediate typewould otherwise be ambiguous.
The API docs contain compile-fail coverage for these cases and for both exclusive
float forms, plus compiling native-range and migration examples. Runtime tests cover
boundaries, invalid defaults, all declaration kinds, generic forwarding, a convertible
enum, unchanged stepped ranges, and ROS descriptor bounds.
Validation
Tested on Windows with native ROS 2 Jazzy and a separate generated Rust interface
overlay. The overlay was produced from installed Jazzy IDL using
rosidl_generator_rsat commit
19d57818dab3b51e418c0893b70b3a1a8b64c495.serdeenabled.serdeenabled.expected compilation failures).
git diff --checkpasses.missing
rmw_qos_profile_best_availablesymbol. An unchanged snapshot of base commitc9b7d93reproduces the identical failed cases. The modified tree adds six passingdoctests, with no additional failures.
--no-deps --all-targets --features serde -- -D warningsfails on theunchanged base too. Comparing diagnostics by message and source file shows no added
diagnostics on either compiler: 121 on stable and 134 on Rust 1.85.
base and modified trees (
dynamic_message/message_structure.rsandlib.rs).Runtime test suites were run serially in separate ROS domains.
No dependency, minimum Rust version, or CI changes are included.
Assisted-by: Codex:GPT-6