mirror of
https://github.com/rust-lang/rust
synced 2024-10-17 22:13:59 +00:00
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:
parent
c52b9c10bf
commit
4a2214885d
|
@ -2626,10 +2626,13 @@ impl<T, A: Allocator> IntoIterator for Vec<T, A> {
|
|||
///
|
||||
/// ```
|
||||
/// let v = vec!["a".to_string(), "b".to_string()];
|
||||
/// for s in v.into_iter() {
|
||||
/// // s has type String, not &String
|
||||
/// println!("{s}");
|
||||
/// }
|
||||
/// let mut v_iter = v.into_iter();
|
||||
///
|
||||
/// 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]
|
||||
fn into_iter(self) -> IntoIter<T, A> {
|
||||
|
|
|
@ -716,6 +716,8 @@ fn revswap<T>(a: &mut [T], b: &mut [T], n: usize) {
|
|||
|
||||
/// Returns an iterator over the slice.
|
||||
///
|
||||
/// The iterator yields all items from start to end.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
|
@ -735,6 +737,8 @@ pub fn iter(&self) -> Iter<'_, T> {
|
|||
|
||||
/// Returns an iterator that allows modifying each value.
|
||||
///
|
||||
/// The iterator yields all items from start to end.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue