Impl conversion from array to Vec#352
Merged
Merged
Conversation
c0aeb9d to
81c61a2
Compare
Closed
329bc41 to
0a5fd1d
Compare
Dirbaio
approved these changes
Jan 1, 2024
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.
This PR implements conversion from arrays to vec. The array does not have to be the same length as the capacity of the vec. Const generics are asserted at compile time. Unfortunately the method currently requires a copy of the source array.
Partially addresses requests in #341 and #344.
Also I'm not totally happy about the const assertions given #351. I've not added any tests in the
cfailsuite as I don't think we can practically check this withtrybuildat the moment. There is a bit of a work-around you can do but it's not pretty.Questions
Would we prefer to just implement
From<[T; N]> for Vec<T, N>? One of the issues with this impl is that users will need to be explicit about vec capacity. Because lengthsNandMcan be different, you can't write:It needs to be:
Should
from_arraybe internal, and the API exposed by the crate simply be theFromtrait?