Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array::try_map #79713

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Swap out Try for Result
  • Loading branch information
eopb committed Dec 30, 2020
commit 892963e3bb5dd6fd8fc302c4c767e0e9d519700a
7 changes: 3 additions & 4 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ use crate::convert::{Infallible, TryFrom};
use crate::fmt;
use crate::hash::{self, Hash};
use crate::marker::Unsize;
use crate::ops::{Index, IndexMut, Try};
use crate::ops::{Index, IndexMut};
use crate::slice::{Iter, IterMut};

mod iter;
Expand Down Expand Up @@ -480,10 480,9 @@ impl<T, const N: usize> [T; N] {
/// assert!(b.is_err());
/// ```
#[unstable(feature = "array_try_map", issue = "79711")]
pub fn try_map<F, R, E, U>(self, mut f: F) -> Result<[U; N], E>
pub fn try_map<F, E, U>(self, mut f: F) -> Result<[U; N], E>
where
F: FnMut(T) -> R,
R: Try<Ok = U, Error = E>,
F: FnMut(T) -> Result<U, E>,
{
use crate::mem::MaybeUninit;
struct Guard<T, const N: usize> {
Expand Down