diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index af661e485f5e1..fba1a5a751c59 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -31,14 +31,12 @@ pub use iter::IntoIter; /// # Example /// /// ```rust -/// #![feature(array_from_fn)] -/// /// let array = core::array::from_fn(|i| i); /// assert_eq!(array, [0, 1, 2, 3, 4]); /// ``` #[inline] -#[unstable(feature = "array_from_fn", issue = "89379")] -pub fn from_fn(mut cb: F) -> [T; N] +#[stable(feature = "array_from_fn", since = "1.63.0")] +pub fn from_fn(mut cb: F) -> [T; N] where F: FnMut(usize) -> T, { @@ -65,7 +63,7 @@ where /// # Example /// /// ```rust -/// #![feature(array_from_fn)] +/// #![feature(array_try_from_fn)] /// /// let array: Result<[u8; 5], _> = std::array::try_from_fn(|i| i.try_into()); /// assert_eq!(array, Ok([0, 1, 2, 3, 4])); @@ -80,8 +78,8 @@ where /// assert_eq!(array, None); /// ``` #[inline] -#[unstable(feature = "array_from_fn", issue = "89379")] -pub fn try_from_fn(cb: F) -> ChangeOutputType +#[unstable(feature = "array_try_from_fn", issue = "89379")] +pub fn try_from_fn(cb: F) -> ChangeOutputType where F: FnMut(usize) -> R, R: Try, diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index ee7ff012ec1c1..f268fe3ae7ba8 100644 --- a/library/core/tests/array.rs +++ b/library/core/tests/array.rs @@ -388,7 +388,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::<_, Result<(), _>, 2>(|_| Err(SomeError::Foo)); + let another_array = core::array::try_from_fn::, 2, _>(|_| Err(SomeError::Foo)); assert_eq!(another_array, Err(SomeError::Foo)); } diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 31b764a6e2d52..004589bbc31cf 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -35,7 +35,7 @@ #![feature(float_minimum_maximum)] #![feature(future_join)] #![feature(future_poll_fn)] -#![feature(array_from_fn)] +#![feature(array_try_from_fn)] #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] #![feature(try_find)]