Add example to array::IntoIter::new’s doc-comment

Co-authored-by: Ashley Mannix <kodraus@hey.com>
This commit is contained in:
Simon Sapin 2021-01-21 15:52:53 +01:00 committed by GitHub
parent 61c49d4042
commit 83d32b0a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,16 @@ impl<T, const N: usize> IntoIter<T, N> {
/// *Note*: this method might be deprecated in the future,
/// after [`IntoIterator` is implemented for arrays][array-into-iter].
///
/// # Examples
///
/// ```
/// use std::array;
///
/// for value in array::IntoIter::new([1, 2, 3, 4, 5]) {
/// // The type of `value` is a `i32` here, instead of `&i32`
/// let _: i32 = value;
/// }
/// ```
/// [array-into-iter]: https://github.com/rust-lang/rust/pull/65819
#[stable(feature = "array_value_iter", since = "1.51.0")]
pub fn new(array: [T; N]) -> Self {