1
Fork 0

Clarify slice and Vec iteration order

While already being inferable from the doc examples, it wasn't
fully specified. This is the only logical way to do a slice
iterator.
This commit is contained in:
Nilstrieb 2022-05-16 19:29:45 +02:00
parent c52b9c10bf
commit 4a2214885d
2 changed files with 11 additions and 4 deletions

View file

@ -2626,10 +2626,13 @@ impl<T, A: Allocator> IntoIterator for Vec<T, A> {
/// ///
/// ``` /// ```
/// let v = vec!["a".to_string(), "b".to_string()]; /// let v = vec!["a".to_string(), "b".to_string()];
/// for s in v.into_iter() { /// let mut v_iter = v.into_iter();
/// // s has type String, not &String ///
/// println!("{s}"); /// let first_element: Option<String> = v_iter.next();
/// } ///
/// assert_eq!(first_element, Some("a".to_string()));
/// assert_eq!(v_iter.next(), Some("b".to_string()));
/// assert_eq!(v_iter.next(), None);
/// ``` /// ```
#[inline] #[inline]
fn into_iter(self) -> IntoIter<T, A> { fn into_iter(self) -> IntoIter<T, A> {

View file

@ -716,6 +716,8 @@ impl<T> [T] {
/// Returns an iterator over the slice. /// Returns an iterator over the slice.
/// ///
/// The iterator yields all items from start to end.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -735,6 +737,8 @@ impl<T> [T] {
/// Returns an iterator that allows modifying each value. /// Returns an iterator that allows modifying each value.
/// ///
/// The iterator yields all items from start to end.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```