Skip to content

Commit

Permalink
Simplify [T; N]::try_map signature
Browse files Browse the repository at this point in the history
People keep making fun of this signature for being so gnarly.
Associated type bounds lend it a much simpler scribbling.
  • Loading branch information
workingjubilee committed Jun 11, 2024
1 parent b5b1356 commit d09382e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,12 @@ impl<T, const N: usize> [T; N] {
/// assert_eq!(c, Some(a));
/// ```
#[unstable(feature = "array_try_map", issue = "79711")]
pub fn try_map<F, R>(self, f: F) -> ChangeOutputType<R, [R::Output; N]>
pub fn try_map<R: Try>(
self,
f: impl FnMut(T) -> R,
) -> <R::Residual as Residual<[R::Output; N]>>::TryType
where
F: FnMut(T) -> R,
R: Try,
R::Residual: Residual<[R::Output; N]>,
R: Try<Residual: Residual<[R::Output; N]>>,
{
drain_array_with(self, |iter| try_from_trusted_iterator(iter.map(f)))
}
Expand Down

0 comments on commit d09382e

Please sign in to comment.