-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl From<[T; N]> for Vec<T> #68692
Merged
+41
−7
Merged
impl From<[T; N]> for Vec<T> #68692
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6272273
impl From<[T; N]> for Vec<T>
jyn514 daeb8ec
fix error compiling stage2
jyn514 f267d9d
limit From impl to LengthAtMost32
jyn514 e3d5eaf
add ui-tests
jyn514 ba46b61
bless UI tests
jyn514 96794d8
fix test failure
jyn514 1ac4a46
make the impl a little prettier
jyn514 8212584
Bump release cutoff
jyn514 3477e67
Allow vec.rs to be over 3000 lines :(
jyn514 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// ignore-tidy-filelength | ||
//! A contiguous growable array type with heap-allocated contents, written | ||
//! `Vec<T>`. | ||
//! | ||
|
@@ -2397,6 +2398,21 @@ impl<T: Clone> From<&mut [T]> for Vec<T> { | |
} | ||
} | ||
|
||
#[stable(feature = "vec_from_array", since = "1.44.0")] | ||
impl<T, const N: usize> From<[T; N]> for Vec<T> | ||
where | ||
[T; N]: LengthAtMost32, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any docs for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need documentation? It looks pretty self-explanatory to me. |
||
#[cfg(not(test))] | ||
fn from(s: [T; N]) -> Vec<T> { | ||
<[T]>::into_vec(box s) | ||
} | ||
#[cfg(test)] | ||
Mark-Simulacrum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn from(s: [T; N]) -> Vec<T> { | ||
crate::slice::into_vec(box s) | ||
LukasKalbertodt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")] | ||
impl<'a, T> From<Cow<'a, [T]>> for Vec<T> | ||
where | ||
|
This file contains 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
This file contains 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
This file contains 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
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.
I'm not quite sure what's the procedure on this and what this tidy check tries to achieve, but it feels like this file could easily be split. There are already multiple sections. It would be easy, for example, to move the iterator stuff out of there (the last section, starting here). It's kind of unfortunate that you have to do it now, since this is unrelated to your PR, but I'd prefer that over the ignore tidy annotation.
But just to get a second opinion: @BurntSushi @withoutboats 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.
The purpose of the tidy check is to avoid gigantic files with poor structure. I think doing it before this PR or after is fine, but someone should sign up for the work.