arrays.parallel: fix v doc -unsafe-run-examples -f none vlib/arrays/parallel/ too

This commit is contained in:
Delyan Angelov 2025-08-13 17:23:44 +03:00
parent c96f0b63f2
commit 9771491c94
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -22,7 +22,7 @@ fn limited_workers(max_workers int, ilen int) int {
// run lets the user run an array of input with a user provided function in parallel.
// It limits the number of worker threads to min(num_workers, num_cpu).
// The function aborts if an error is encountered.
// Example: parallel.run([1, 2, 3, 4, 5], 2, fn (i) { println(i) })
// Example: parallel.run([1, 2, 3, 4, 5], |i| println(i))
pub fn run[T](input []T, worker fn (T), opt Params) {
if input.len == 0 {
return
@ -61,7 +61,7 @@ struct Task[T, R] {
// It limits the number of worker threads to max number of cpus.
// The worker function can return a value. The returning array maintains the input order.
// Any error handling should have happened within the worker function.
// Example: squares := parallel.amap([1, 2, 3, 4, 5], 2, fn (i) { return i * i })
// Example: squares := parallel.amap([1, 2, 3, 4, 5], |i| i * i); assert squares == [1, 4, 9, 16, 25]
pub fn amap[T, R](input []T, worker fn (T) R, opt Params) []R {
if input.len == 0 {
return []