added proc rand for typedesc (#10259)
This commit is contained in:
parent
d983d998b2
commit
2b37bf5d5b
1 changed files with 5 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue