rand: minor cleanup in choose() (#14376)

yuyi 2022-05-12 16:20:38 +08:00 committed by Jef Roosens
parent a8dceb74ec
commit 49d57dfccd
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 1 additions and 3 deletions

View File

@ -327,9 +327,7 @@ pub fn (mut rng PRNG) choose<T>(array []T, k int) ?[]T {
}
mut results := []T{len: k}
mut indices := []int{len: n, init: it}
// TODO: see why exactly it is necessary to enfoce the type here in Checker.infer_fn_generic_types
// (v errors with: `inferred generic type T is ambiguous: got int, expected string`, when <int> is missing)
rng.shuffle<int>(mut indices) ?
rng.shuffle(mut indices) ?
for i in 0 .. k {
results[i] = array[indices[i]]
}