Accept all refspecs that implement AsRef<str> #482
Merged
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.
This changes the signature of the
Remote::fetch
andRemote::push
methods to accept refspecs as slices over not only&str
but anything that implementsAsRef<str>
(as well asIntoCString
andClone
). In this way, refspecs can be provided, for example, by a&Vec<String>
, which wasn’t possible before.The reason I’d like to contribute this change is that I’m in a situation where I retrieve remote references with
RemoteConnection::list
and turn them into a list of refspecs I want to fetch (or push), leaving me with aVec<String>
of refspecs. However, in order to callRemote::fetch
(orRemote::push
), I currently have to allocate a newVec<&str>
from thisVec<String>
, which I’d like to avoid if possible.I’m still in the process of learning Rust, so I hope that this change and my explanations make sense 🙂. As far as I can tell, it’s not a breaking change in the sense that existing code using
Remote::fetch
andRemote::push
should still be working.