Skip to content

Commit af27040

Browse files
LukasKalbertodtcuviper
authored andcommitted
Adjust docs and tests for new IntoIterator impl for arrays
1 parent 6df7420 commit af27040

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

std/src/primitive_docs.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ mod prim_pointer {}
498498
/// - [`Copy`]
499499
/// - [`Clone`]
500500
/// - [`Debug`]
501-
/// - [`IntoIterator`] (implemented for `&[T; N]` and `&mut [T; N]`)
501+
/// - [`IntoIterator`] (implemented for `[T; N]`, `&[T; N]` and `&mut [T; N]`)
502502
/// - [`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]
503503
/// - [`Hash`]
504504
/// - [`AsRef`], [`AsMut`]
@@ -526,31 +526,16 @@ mod prim_pointer {}
526526
/// assert_eq!([1, 2], &array[1..]);
527527
///
528528
/// // This loop prints: 0 1 2
529-
/// for x in &array {
529+
/// for x in array {
530530
/// print!("{} ", x);
531531
/// }
532532
/// ```
533533
///
534-
/// An array itself is not iterable:
535-
///
536-
/// ```compile_fail,E0277
537-
/// let array: [i32; 3] = [0; 3];
538-
///
539-
/// for x in array { }
540-
/// // error: the trait bound `[i32; 3]: std::iter::Iterator` is not satisfied
541-
/// ```
542-
///
543-
/// The solution is to coerce the array to a slice by calling a slice method:
534+
/// You can also iterate over reference to the array's elements:
544535
///
545536
/// ```
546-
/// # let array: [i32; 3] = [0; 3];
547-
/// for x in array.iter() { }
548-
/// ```
549-
///
550-
/// You can also use the array reference's [`IntoIterator`] implementation:
537+
/// let array: [i32; 3] = [0; 3];
551538
///
552-
/// ```
553-
/// # let array: [i32; 3] = [0; 3];
554539
/// for x in &array { }
555540
/// ```
556541
///

0 commit comments

Comments
 (0)