-
Notifications
You must be signed in to change notification settings - Fork 323
Add into_scalar method for Array0 #535
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
Conversation
cb05c2e
to
6273494
Compare
356204b
to
d859202
Compare
This would avoid using the |
let index = (first - base) / size; | ||
debug_assert_eq!((first - base) % size, 0); | ||
// Remove the element at that index and return it. | ||
self.data.0.remove(index) |
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.
Gnarly but it works fine. Maybe a comment to explain that the len of the Vec might be bigger than the array's current len
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.
Okay, I've added a explanatory comment. If someone changes the implementation in the future, the test will also help catch this edge case.
d859202
to
60d3b97
Compare
Do you think it would make sense to add |
Never mind. I think |
Other possible names:
into_first
,into_inner
,unwrap
.Edit: I just realized the implementation is broken and I need to fix it. Don't merge this yet!
Edit2: Fixed now! (See the first part of the
array0_into_scalar
test for the case where my original implementation was broken.)