Rollup merge of #106186 - rossmacarthur:ft/iter-chain, r=Amanieu · model-checking/verify-rust-std@1764910 (original) (raw)

`@@ -4,8 +4,8 @@ use crate::ops::Try;

`

4

4

``

5

5

`/// An iterator that links two iterators together, in a chain.

`

6

6

`///

`

7

``

`` -

/// This struct is created by [Iterator::chain]. See its documentation

``

8

``

`-

/// for more.

`

``

7

`` +

/// This struct is created by [chain] or [Iterator::chain]. See their

``

``

8

`+

/// documentation for more.

`

9

9

`///

`

10

10

`/// # Examples

`

11

11

`///

`

`@@ -38,6 +38,39 @@ impl<A, B> Chain<A, B> {

`

38

38

`}

`

39

39

`}

`

40

40

``

``

41

`+

/// Converts the arguments to iterators and links them together, in a chain.

`

``

42

`+

///

`

``

43

`` +

/// See the documentation of [Iterator::chain] for more.

``

``

44

`+

///

`

``

45

`+

/// # Examples

`

``

46

`+

///

`

``

47


/// ```

``

48

`+

/// #![feature(iter_chain)]

`

``

49

`+

///

`

``

50

`+

/// use std::iter::chain;

`

``

51

`+

///

`

``

52

`+

/// let a = [1, 2, 3];

`

``

53

`+

/// let b = [4, 5, 6];

`

``

54

`+

///

`

``

55

`+

/// let mut iter = chain(a, b);

`

``

56

`+

///

`

``

57

`+

/// assert_eq!(iter.next(), Some(1));

`

``

58

`+

/// assert_eq!(iter.next(), Some(2));

`

``

59

`+

/// assert_eq!(iter.next(), Some(3));

`

``

60

`+

/// assert_eq!(iter.next(), Some(4));

`

``

61

`+

/// assert_eq!(iter.next(), Some(5));

`

``

62

`+

/// assert_eq!(iter.next(), Some(6));

`

``

63

`+

/// assert_eq!(iter.next(), None);

`

``

64


/// ```

``

65

`+

#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")]

`

``

66

`+

pub fn chain<A, B>(a: A, b: B) -> Chain<A::IntoIter, B::IntoIter>

`

``

67

`+

where

`

``

68

`+

A: IntoIterator,

`

``

69

`+

B: IntoIterator<Item = A::Item>,

`

``

70

`+

{

`

``

71

`+

Chain::new(a.into_iter(), b.into_iter())

`

``

72

`+

}

`

``

73

+

41

74

`#[stable(feature = "rust1", since = "1.0.0")]

`

42

75

`impl<A, B> Iterator for Chain<A, B>

`

43

76

`where

`