Skip to content

Commit 1193cef

Browse files
Simplify [T; N]::try_map signature
People keep making fun of this signature for being so gnarly. Associated type bounds lend it a much simpler scribbling.
1 parent b5b1356 commit 1193cef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/core/src/array/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,12 @@ impl<T, const N: usize> [T; N] {
533533
/// assert_eq!(c, Some(a));
534534
/// ```
535535
#[unstable(feature = "array_try_map", issue = "79711")]
536-
pub fn try_map<F, R>(self, f: F) -> ChangeOutputType<R, [R::Output; N]>
536+
pub fn try_map<R>(
537+
self,
538+
f: impl FnMut(T) -> R,
539+
) -> <R::Residual as Residual<[R::Output; N]>>::TryType
537540
where
538-
F: FnMut(T) -> R,
539-
R: Try,
540-
R::Residual: Residual<[R::Output; N]>,
541+
R: Try<Residual: Residual<[R::Output; N]>>,
541542
{
542543
drain_array_with(self, |iter| try_from_trusted_iterator(iter.map(f)))
543544
}

0 commit comments

Comments
 (0)