Skip to content
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

Add additional array -> array view conversions #1130

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

bluss
Copy link
Member

@bluss bluss commented Dec 6, 2021

It is best to be "complete" with implementations when possible, since
it can always be a breaking change to add it later.

As shown in the test change in this commit, this is a minor type
inference breakage due to ArrayView::from(&[]) being ambiguous.

Empty array views should be relatively rare - and one can use
ArrayView1 or other means to disambiguate.

Copy link
Member

@jturner314 jturner314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me, except for one comment about the docs.

/// Implementation of ArrayView2::from(&[[A; N]; M])
///
/// **Panics** if the product of non-zero axis lengths overflows `isize` (This can only occur if A
/// is zero-sized because slices cannot contain more than `isize::MAX` number of bytes).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment and the one for ArrayViewMut should mention that another panicking case is when N == 0 and the number of rows is greater than isize::MAX, even if A is not zero-sized. (See #1131.)

@bluss bluss force-pushed the array-view-from branch 2 times, most recently from ea5cf10 to cf9316a Compare March 14, 2024 21:22
It is best to be "complete" with implementations when possible, since
it can always be a breaking change to add it later.

As shown in the test change in this commit, this is a minor type
inference breakage due to `ArrayView::from(&[])` being ambiguous.

Empty array views should be relatively rare - and one can use
`ArrayView1` or other means to disambiguate.
@bluss bluss force-pushed the array-view-from branch from cf9316a to 646de85 Compare March 14, 2024 21:23
@bluss bluss enabled auto-merge March 14, 2024 21:30
@bluss bluss added this pull request to the merge queue Mar 14, 2024
Merged via the queue into master with commit d37c0c8 Mar 14, 2024
10 checks passed
@bluss bluss deleted the array-view-from branch March 14, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants