]> git.lizzy.rs Git - rust.git/commitdiff
Add example to array::IntoIter::new’s doc-comment
authorSimon Sapin <simon.sapin@exyr.org>
Thu, 21 Jan 2021 14:52:53 +0000 (15:52 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Jan 2021 14:52:53 +0000 (15:52 +0100)
Co-authored-by: Ashley Mannix <kodraus@hey.com>
library/core/src/array/iter.rs

index 0fd8815570bd77001a3f974859ed9ca1b8631973..535291471b1d0e9b33a6b1399a65a4e2965bbfdf 100644 (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 {