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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach forces an allocation of a
Vec
, most likely unnecessarily. I see a few alternative return types:&Vec<Arc<String>>
: most direct, loses no power versus this return type, but exposes internals of the library (the presence of theArc
). Given that we aren't provided API stability right now, I don't see a problem with that last part.&[Arc<String>]
: very similar to the above. I've actually never figured out whether it's more idiomatic to return a&Vec
or&[]
from a function. (For input, it's always better to take the slice to make the API more general.)impl Iterator<&str>
: best for hiding the internal API, doesn't add any cost, but slightly less flexible on the calling sideI slightly lean towards the first option. @psibi what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case we choose the first option, there's no need to have this additional method but change the visibility of the
grpc_fallback_urls
method.cosmos-rs/packages/cosmos/src/cosmos_builder.rs
Lines 123 to 125 in 207c67a
What do you think @snoyberg ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely a true statement. However, the advantage of keeping the field private is it gives more flexibility in the future to update the API. But given my other comments about not providing API compatibility, it's not strictly necessary. I kept it that way up until now because it was easy enough to provide the getter/setter approach. I'm not convinced it's worth it, so certainly open to changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I'm gonna change the visibility of
grpc_fallback_urls
method and remove the current change.