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:
parent
60eac79f7f
commit
d1d2498c7b
1 changed files with 1 additions and 1 deletions
|
|
@ -410,7 +410,7 @@ proc sample*[T](r: var Rand; a: openArray[T]): T =
|
||||||
|
|
||||||
result = a[r.rand(a.low..a.high)]
|
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`.
|
## Returns a random element from `a`.
|
||||||
##
|
##
|
||||||
## If `randomize <#randomize>`_ has not been called, the order of outcomes
|
## If `randomize <#randomize>`_ has not been called, the order of outcomes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue