Skip to content

Commit 2ce74b0

Browse files
authored
Rollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu
Update primitive docs for rust 2021. Fixes #87701
2 parents e13b9c9 + 00c8da1 commit 2ce74b0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

library/std/src/primitive_docs.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ mod prim_pointer {}
581581
/// might be made consistent to the behavior of later editions.
582582
///
583583
/// ```rust,edition2018
584+
/// // Rust 2015 and 2018:
585+
///
584586
/// # #![allow(array_into_iter)] // override our `deny(warnings)`
585587
/// let array: [i32; 3] = [0; 3];
586588
///
@@ -604,11 +606,13 @@ mod prim_pointer {}
604606
/// }
605607
/// ```
606608
///
607-
/// Starting in the 2021 edition, `array.into_iter()` will use `IntoIterator` normally to iterate
609+
/// Starting in the 2021 edition, `array.into_iter()` uses `IntoIterator` normally to iterate
608610
/// by value, and `iter()` should be used to iterate by reference like previous editions.
609611
///
610-
/// ```rust,edition2021,ignore
611-
/// # // FIXME: ignored because 2021 testing is still unstable
612+
#[cfg_attr(bootstrap, doc = "```rust,edition2021,ignore")]
613+
#[cfg_attr(not(bootstrap), doc = "```rust,edition2021")]
614+
/// // Rust 2021:
615+
///
612616
/// let array: [i32; 3] = [0; 3];
613617
///
614618
/// // This iterates by reference:
@@ -631,12 +635,12 @@ mod prim_pointer {}
631635
/// avoid the `into_iter` syntax on those editions. If an edition update is not
632636
/// viable/desired, there are multiple alternatives:
633637
/// * use `iter`, equivalent to the old behavior, creating references
634-
/// * use [`array::IntoIter`], equivalent to the post-2021 behavior (Rust 1.51+)
638+
/// * use [`IntoIterator::into_iter`], equivalent to the post-2021 behavior (Rust 1.53+)
635639
/// * replace `for ... in array.into_iter() {` with `for ... in array {`,
636640
/// equivalent to the post-2021 behavior (Rust 1.53+)
637641
///
638642
/// ```rust,edition2018
639-
/// use std::array::IntoIter;
643+
/// // Rust 2015 and 2018:
640644
///
641645
/// let array: [i32; 3] = [0; 3];
642646
///
@@ -647,7 +651,7 @@ mod prim_pointer {}
647651
/// }
648652
///
649653
/// // This iterates by value:
650-
/// for item in IntoIter::new(array) {
654+
/// for item in IntoIterator::into_iter(array) {
651655
/// let x: i32 = item;
652656
/// println!("{}", x);
653657
/// }
@@ -660,7 +664,7 @@ mod prim_pointer {}
660664
///
661665
/// // IntoIter can also start a chain.
662666
/// // This iterates by value:
663-
/// for item in IntoIter::new(array).enumerate() {
667+
/// for item in IntoIterator::into_iter(array).enumerate() {
664668
/// let (i, x): (usize, i32) = item;
665669
/// println!("array[{}] = {}", i, x);
666670
/// }

0 commit comments

Comments
 (0)