Make array::{try_from_fn, try_map} and Iterator::try_find generic over Try by scottmcm · Pull Request #91286 · rust-lang/rust (original) (raw)

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 22, 2022

@bors

…ttmcm

Stabilize array_from_fn

Overall

Stabilizes core::array::from_fn and core::array::try_from_fn to allow the creation of custom infallible and fallible arrays.

Signature proposed for stabilization here, tweaked as requested in the meeting:

// in core::array

pub fn from_fn<T, const N: usize, F>(_: F) -> [T; N];

Examples in https://doc.rust-lang.org/nightly/std/array/fn.from_fn.html

History

Considerations

These considerations are not ways of saying what is better or what is worse. In reality, they are an attempt to move things forward, anything really.

cc rust-lang#89379