diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-06-12 03:57:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 03:57:21 -0700 |
| commit | 4de77b6d8ad84a494c5b74b23ce4973b4f3dad0f (patch) | |
| tree | 41f8b1e8685cecc70ef4bb2b198248d3e28f39fe | |
| parent | 3a37293e9271c391f5883d5d2e8624197d47dc8f (diff) | |
| parent | d6955445f53062a8af3e5a4e84dbf756a7913cbe (diff) | |
| download | rust-4de77b6d8ad84a494c5b74b23ce4973b4f3dad0f.tar.gz rust-4de77b6d8ad84a494c5b74b23ce4973b4f3dad0f.zip | |
Rollup merge of #126249 - workingjubilee:simplify-try-map-signature, r=scottmcm
Simplify `[T; N]::try_map` signature People keep making fun of this signature for being so gnarly. Associated type bounds admit a much simpler scribbling. r? ````@scottmcm````
| -rw-r--r-- | library/core/src/array/mod.rs | 6 | ||||
| -rw-r--r-- | library/core/src/ops/try_trait.rs | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 05874ab6c4c..2569ce23707 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -533,11 +533,9 @@ 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>(self, f: impl FnMut(T) -> R) -> ChangeOutputType<R, [R::Output; N]> 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))) } diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index 483f55b2070..cd444c86ed0 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -363,7 +363,9 @@ pub trait Residual<O> { } #[unstable(feature = "pub_crate_should_not_need_unstable_attr", issue = "none")] -pub(crate) type ChangeOutputType<T, V> = <<T as Try>::Residual as Residual<V>>::TryType; +#[allow(type_alias_bounds)] +pub(crate) type ChangeOutputType<T: Try<Residual: Residual<V>>, V> = + <T::Residual as Residual<V>>::TryType; /// An adapter for implementing non-try methods via the `Try` implementation. /// |
