-
Notifications
You must be signed in to change notification settings - Fork 45
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
implemented array push #4232
implemented array push #4232
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This technically works, but if anyone pushes inside a loop, it's O(n^2). Do we really want to introduce this? Seems like a big foot-gun. I will propose an alternative in the issue. |
I haven't reviewed this but I'd be happy to merge for now on the understanding that we need to review all our array functionality and probably change both the interfaces and implementation. I think re-implementing arrays using some kind of other data structure would be a big job and we shouldn't do that until we have a proper plan |
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.
Can you add another test that pushes to an array and tries to get the new element's index on the original array? Using gen_test_fail!()
, we assert that it fails since the original array shouldn't get modified. As far as I know, we don't yet have a way to get the length of an array.
Succeeded by #4341 |
Addressing feature request from #4127, added array std lib function 'push' which takes in an array and an element, and returns a new array with the element appended to the end.