Add lent annotation to avoid extra copies in sample (#18404)

* Add lent annotation to avoid extra copies in sample

* Remove lent

* Update random.nim
This commit is contained in:
Antonis Geralis 2021-07-03 00:20:59 +03:00 • committed by GitHub
commit d1d2498c7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -410,7 +410,7 @@ proc sample*[T](r: var Rand; a: openArray[T]): T =
result = a[r.rand(a.low..a.high)]
proc sample*[T](a: openArray[T]): T =
proc sample*[T](a: openArray[T]): lent T =
## Returns a random element from `a`.
##
## If `randomize <#randomize>`_ has not been called, the order of outcomes