]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se
authorYuki Okushi <jtitor@2k36.org>
Fri, 30 Jul 2021 19:09:33 +0000 (04:09 +0900)
committerGitHub <noreply@github.com>
Fri, 30 Jul 2021 19:09:33 +0000 (04:09 +0900)
commitf4dfb76ea1f1312c6602a0ab24ec64f976c0a281
tree78fda86889c9eeb6838a38c45ed9b7197c621d04
parent2bdc54fb4570a8bb82019bb00049feefdf8ac585
parent5cc7702bde47716c66734c488432850fab1a83dd
Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se

Add docs about performance and `Iterator::map` to `[T; N]::map`

This suboptimal code gen for some usages of array::map got a bit of
attention by multiple people throughout the community. Some cases:

- https://github.com/rust-lang/rust/issues/75243#issuecomment-866051086
- https://github.com/rust-lang/rust/issues/75243#issuecomment-874732134
- https://www.reddit.com/r/rust/comments/oeqqf7/unexpected_high_stack_usage/

My *guess* is that this gets the attention it gets because in JavaScript
(and potentially other languages), a `map` function on arrays is very
commonly used since in those languages, arrays basically take the role
of Rust's iterator. I considered explicitly naming JavaScript in the
first paragraph I added, but I couldn't find precedence of mentioning
other languages in standard library doc, so I didn't add it.

When array::map was stabilized, we still wanted to add docs, but that
somehow did not happen in time. So here we are. Not sure if this sounds
crazy but maybe it is worth considering beta backporting this? Only if
it's not a lot of work, of course! But yeah, stabilized array::map is
already in beta and if this problem is really as big as it sometimes seems,
might be worth having the docs in place when 1.55 is released.

CC ``@CryZe``

r? ``@m-ou-se`` (since you were involved in that discussion and the stabilization)