Enable to take non-model type as index part of Array ops#135
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 549bc830ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| impl<I, T> std::ops::Index<I> for Array<I, T> { | ||
| impl<I, T, U> std::ops::Index<U> for Array<I, T> where U: super::Model<Ty = I> { |
There was a problem hiding this comment.
Preserve exact array indexing for generic model indices
When a spec/helper is generic over the array's model index type, e.g. fn f<I: thrust_models::Model, T>(a: Array<I, T>, i: I) { let _ = &a[i]; }, this impl no longer applies unless <I as Model>::Ty == I. The previous Index<I> impl accepted that exact model index, but the new bound only supports source types that lower to I, so polymorphic array specs and arrays indexed by non-self model types are rejected at type checking; the same restriction was added to store below.
Useful? React with 👍 / 👎.
small fix to index into Array<Int, T> by integer constant literal