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 UnsafeRichArray#at
syntax extension
#2888
Add UnsafeRichArray#at
syntax extension
#2888
Conversation
/** Scala Native unsafe extensions to Arrays */ | ||
implicit class UnsafeRichArray[T](val value: Array[T]) extends AnyVal { | ||
@inline def at(i: Int): Ptr[T] = value.asInstanceOf[runtime.Array[T]].at(i) | ||
} |
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.
This is the new syntax, all other modifications are applying it.
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.
LGTM Makes the code much clearer and reduces the hackery.
A HUGE thank you for getting this done.
I suspect that my pending PR #2877 has quite a few places which will This PR makes it much easier to get the idiom right. Should make maintenance |
Do you think the "at" method name is specific enough? |
* Add `UnsafeRichArray#at` syntax extension * Use it more
* Add `UnsafeRichArray#at` syntax extension * Use it more
* Add `UnsafeRichArray#at` syntax extension * Use it more
This PR exposes an unsafe syntax extension for retrieving the
Ptr
backing an array, making official the widely-used trick of casting to aruntime.Array
and accessing it like that.The new syntax is then adopted within the codebase.