Add entries
to MapBuilder
to return both key and value array builders
#5218
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.
Which issue does this PR close?
Closes #.
Rationale for this change
MapBuilder
provideskeys
andvalues
functions to get key and value array builders of map separately. As it is mutable borrow of the map builder, when we want to set keys and values in a loop like:The compiler will complain
error[E0499]: cannot borrow
*builderas mutable more than once at a time
.Although there is workaround that is to get key and value builders inside the loop, no sure if it is efficient. More, especially we can have
Box<dyn ArrayBuilder>
as key and value builders now, it means that we need todowncast
both key and value builders for each iteration in the loop.This patch adds
entries
API toMapBuilder
that can get both key and value builders in one mutable borrow.What changes are included in this PR?
Are there any user-facing changes?