1
Fork 0

Make array::{try_from_fn, try_map} and Iterator::try_find generic over Try

Fixes 85115

This only updates unstable functions.

`array::try_map` didn't actually exist before, despite the tracking issue 79711 still being open from the old PR 79713.
This commit is contained in:
Scott McMurray 2021-11-26 23:09:34 -08:00
parent e5038e2099
commit b96b9b4093
8 changed files with 195 additions and 45 deletions

View file

@ -377,7 +377,7 @@ fn array_try_from_fn() {
let array = core::array::try_from_fn(|i| Ok::<_, SomeError>(i));
assert_eq!(array, Ok([0, 1, 2, 3, 4]));
let another_array = core::array::try_from_fn::<SomeError, _, (), 2>(|_| Err(SomeError::Foo));
let another_array = core::array::try_from_fn::<_, Result<(), _>, 2>(|_| Err(SomeError::Foo));
assert_eq!(another_array, Err(SomeError::Foo));
}