Skip to content

Commit

Permalink
Rollup merge of #112096 - workingjubilee:array-unzip, r=scottmcm
Browse files Browse the repository at this point in the history
Remove array_zip

`[T; N]::zip` is "eager" but most zips are mapped. This causes poor optimization in generated code. This is a fundamental design issue and "zip" is "prime real estate" in terms of function names, so let's free it up again.

- FCP concluded in rust-lang/rust#80094 (comment)
- Closes rust-lang/rust#80094
- Closes rust-lang/rust#103555

Could use review to make sure we aren't losing any essential codegen tests.
r? `@scottmcm`
  • Loading branch information
matthiaskrgr authored May 31, 2023
2 parents beac94e + ffe677f commit a9e5f5c
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,29 +538,6 @@ impl<T, const N: usize> [T; N] {
drain_array_with(self, |iter| try_from_trusted_iterator(iter.map(f)))
}

/// 'Zips up' two arrays into a single array of pairs.
///
/// `zip()` returns a new array where every element is a tuple where the
/// first element comes from the first array, and the second element comes
/// from the second array. In other words, it zips two arrays together,
/// into a single one.
///
/// # Examples
///
/// ```
/// #![feature(array_zip)]
/// let x = [1, 2, 3];
/// let y = [4, 5, 6];
/// let z = x.zip(y);
/// assert_eq!(z, [(1, 4), (2, 5), (3, 6)]);
/// ```
#[unstable(feature = "array_zip", issue = "80094")]
pub fn zip<U>(self, rhs: [U; N]) -> [(T, U); N] {
drain_array_with(self, |lhs| {
drain_array_with(rhs, |rhs| from_trusted_iterator(crate::iter::zip(lhs, rhs)))
})
}

/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
#[stable(feature = "array_as_slice", since = "1.57.0")]
#[rustc_const_stable(feature = "array_as_slice", since = "1.57.0")]
Expand Down

0 comments on commit a9e5f5c

Please sign in to comment.