added proc rand for typedesc (#10259)

This commit is contained in:
Arne Döring
2019-01-14 09:20:31 +01:00
committed by Andreas Rumpf
parent d983d998b2
commit 2b37bf5d5b

View File

@@ -158,10 +158,14 @@ proc rand*[T](x: HSlice[T, T]): T =
result = rand(state, x)
proc rand*[T](r: var Rand; a: openArray[T]): T {.deprecated.} =
## returns a random element from the openarray `a`.
## Returns a random element from the openarray `a`.
## **Deprecated since v0.20.0:** use ``sample`` instead.
result = a[rand(r, a.low..a.high)]
proc rand*[T: SomeInteger](t: typedesc[T]): T =
## Returns a random integer in the range `low(T)..high(T)`.
result = cast[T](state.next)
proc rand*[T](a: openArray[T]): T {.deprecated.} =
## returns a random element from the openarray `a`.
## **Deprecated since v0.20.0:** use ``sample`` instead.