-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Obtain an immutable array from a mutable one #8826
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
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
library/src/scala/IArray.scala
Outdated
@@ -268,6 +268,9 @@ object IArray { | |||
// A convenience to avoid having to cast everything by hand | |||
private given [A] as Conversion[Array[A], IArray[A]] = identity[Sub[A]] | |||
|
|||
/** Obtain an immutable array from a mutable one. */ | |||
def apply[T](s: Array[T]): IArray[T] = s |
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 unsafe, so it should be called something like unsafeFromArray
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 with this more complete description
library/src/scala/IArray.scala
Outdated
@@ -268,6 +268,9 @@ object IArray { | |||
// A convenience to avoid having to cast everything by hand | |||
private given [A] as Conversion[Array[A], IArray[A]] = identity[Sub[A]] | |||
|
|||
/** Obtain an immutable array from a mutable one. */ |
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.
/** Obtain an immutable array from a mutable one. */ | |
/** Convert an array into an immutable array without copying, the original array | |
* must _not_ be mutated after this or the guaranteed immutablity of IArray will | |
* be violated. | |
*/ |
I don't think we should have this at all. We don't have |
But we do have |
|
Java never encodes immutability in the type system, so |
No description provided.