Skip to content

Commit bb37aeb

Browse files
committed
Obtain an immutable array from a mutable one
1 parent dd42e2a commit bb37aeb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/src/scala/IArray.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ object IArray {
268268
// A convenience to avoid having to cast everything by hand
269269
private given [A] as Conversion[Array[A], IArray[A]] = identity[Sub[A]]
270270

271+
/** Convert an array into an immutable array without copying the original array. */
272+
def unsafeFromArray[T](s: Array[T]): IArray[T] = s
273+
271274
/** An immutable array of length 0. */
272275
def empty[T: ClassTag]: IArray[T] = new Array[T](0)
273276

0 commit comments

Comments
 (0)