Location (URL)
https://doc.rust-lang.org/core/array/fn.from_fn.html
|
/// You can also capture things, for example to create an array full of clones |
|
/// where you can't just use `[item; N]` because it's not `Copy`: |
|
/// ``` |
|
/// # // TBH `array::repeat` would be better for this, but it's not stable yet. |
|
/// let my_string = String::from("Hello"); |
|
/// let clones: [String; 42] = std::array::from_fn(|_| my_string.clone()); |
|
/// assert!(clones.iter().all(|x| *x == my_string)); |
|
/// ``` |
It is not immediately visible to the user, but when the code is executed, comments follow in the playground.
Summary
std::array::repeat is now stable, so it seems necessary to update the comment or revise the example.
Location (URL)
https://doc.rust-lang.org/core/array/fn.from_fn.html
rust/library/core/src/array/mod.rs
Lines 90 to 97 in 44860d3
It is not immediately visible to the user, but when the code is executed, comments follow in the playground.
Summary
std::array::repeatis now stable, so it seems necessary to update the comment or revise the example.