feat(dynamic_message): add DynamicSequence length helpers#591
Open
bresilla wants to merge 1 commit intoros2-rust:mainfrom
Open
feat(dynamic_message): add DynamicSequence length helpers#591bresilla wants to merge 1 commit intoros2-rust:mainfrom
bresilla wants to merge 1 commit intoros2-rust:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds ergonomic helper methods to dynamic message sequence types to improve ease of use when working with nested messages.
Changes:
- Added
len()andis_empty()methods to all four sequence types for querying sequence length - Added
iter()method to immutable sequence types (DynamicSequenceandDynamicBoundedSequence) - Reformatted imports to use nested import syntax
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
luca-della-vedova
left a comment
There was a problem hiding this comment.
I believe but please correct me if I'm wrong that since all the types implement Deref which just returns the inner slice, we can just deref the sequences through * then we should be able to use all of Rust's slice APIs (i.e. is_empty) so we wouldn't need to implement any ourselves
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.
What
Adds small ergonomic helpers to dynamic message sequences:
len()/is_empty()forDynamicSequence,DynamicBoundedSequence,DynamicSequenceMut,DynamicBoundedSequenceMutiter()for immutable sequencesWhy
Makes it easier to traverse dynamic message sequences (especially sequences of nested messages) without reaching into internal storage.
Notes
cargo testpasses.