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
…ttmcm
Stabilize array_from_fn
Overall
Stabilizes core::array::from_fn and to allow the creation of custom infallible core::array::try_from_fnand 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
- On 2020-08-17, implementation was proposed.
- On 2021-09-29, tracking issue was created.
- On 2021-10-09, the proposed implementation was merged.
- On 2021-12-03, the return type of
try_from_fnwas [changed](rust-lang#91286 (comment)).
Considerations
- It is being assumed that indices are useful and shouldn't be removed from the callbacks
- The fact that
try_from_fnreturns an unstable typeR: Trydoes not prevent stabilization. Although I'm honestly not sure about it. - The addition or not of repeat-like variants is orthogonal to this PR.
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.