-
Notifications
You must be signed in to change notification settings - Fork 84
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
feat(array): impl public methods of Array for ArrayView #1275
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 4133Details
💛 - Coveralls |
Could you please run |
Sure. I will do it once I add the rest functions. Edited: Done. |
5dc8636
to
bb2cfa9
Compare
Off-topic: It seems that running |
f10dd6d
to
cb3766e
Compare
hi @FlammeShadow thanks for your contributions. For |
@@ -169,3 +169,144 @@ pub fn rev_foldi[A, B]( | |||
acc | |||
} | |||
} | |||
|
|||
///| | |||
pub fn map[T, U](self : ArrayView[T], f : (T) -> U) -> ArrayView[U] { |
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.
I am really needing the ability to map an ArrayView
in my own code, so I wrote this PR: #1321.
After I wrote that, I found this PR, but am not happy about the implementation found here.
I believe that it is MUCH more flexible for the map*
functions to return an Array
(not an ArrayView
).
Then, code that was performing a map on an entire array could easily insert a [1:]
and now map all but the first entry without modifying any other code.
Additionally, it is much easier to turn an Array
into an ArrayView
than to go the other direction.
ArrayView
should have all the public methods thatArray
has #1013Most of the implementation of functions and tests are taken from
Array
, except for some slight changes.Some notes:
ArrayView
start
andend
are immutable.repeat
flatten
ArrayView[ArrayView[T]]
.Array[Array[T]]
are directly transformed into returningArrayView[ArrayView[T]]
.push_iter
at now. (migrating toUninitializedArray::unsafe_blit
?)rev
,flatten
maybe naive.op_equal
doesn't concernstart
andend
.