Description
Location
https://doc.rust-lang.org/std/array/fn.from_fn.html and https://doc.rust-lang.org/core/array/fn.from_fn.html
Summary
The documentation for from_fn
states
Creates an array [T; N] where each array element T is returned by the cb call.
Arguments
- cb: Callback where the passed argument is the current array index.
It is not clear what "current array index" refers to, since the function description doesn't necessarily indicate that there is iteration happening to create the resulting array.
Additionally, the first line summary doesn't actually reflect the behavior of the function at all. It mentions "the cb call" -- as if there is only one call to cb
.
I think would be more clear if the documentation somehow mentioned that the i
-th element in the output array is the result of calling cb(i)
.
The function try_from_fn
is similarly unclear. Anyone have thoughts on this?