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
Add IntoIterator for
&Vec<>
.Why
To improve the ergonomics of using the
soroban_sdk::Vec
type.So that it is possible to do
for _ in &vec
. So it is possible to iterate a vec without moving it.Today if a developer would like to iterate a Vec without moving it, they need to write
for _ in vec.iter()
. This pattern is a little odd because ordinarily a developer just passes&vec
to iterate without moving.Note that iterating
&vec
will still be somewhat different than it would be to iterate a ref of astd::vec::Vec
from the Rust std library. This is because the Rust std libraryVec
when iterating a vec is iterating refs to items in the vec. When iterating asoroban_sdk::Vec
there is no items in memory to ref, rather during iteration each item is communicated across the host-guest interface and must be passed by value as no one is holding onto its value.