Skip to content

Commit

Permalink
Add lent annotation to avoid extra copies in sample (#18404)
Browse files Browse the repository at this point in the history
* Add lent annotation to avoid extra copies in sample

* Remove lent

* Update random.nim
  • Loading branch information
planetis-m authored Jul 2, 2021
1 parent 60eac79 commit d1d2498
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pure/random.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d1d2498

Please sign in to comment.