Struct std::collections::linked_list::IterMutStable [-] [+] [src]

pub struct IterMut<'a, T> where T: 'a {
    // some fields omitted
}

An iterator over mutable references to the items of a LinkedList.

Methods

impl<'a, A> IterMut<'a, A>

fn insert_next(&mut self, elt: A)

Inserts elt just after the element most recently returned by .next(). The inserted element does not appear in the iteration.

Examples

fn main() { use std::collections::LinkedList; let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); { let mut it = list.iter_mut(); assert_eq!(it.next().unwrap(), &1); // insert `2` after `1` it.insert_next(2); } { let vec: Vec<_> = list.into_iter().collect(); assert_eq!(vec, vec![1, 2, 3, 4]); } }
use std::collections::LinkedList;

let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();

{
    let mut it = list.iter_mut();
    assert_eq!(it.next().unwrap(), &1);
    // insert `2` after `1`
    it.insert_next(2);
}
{
    let vec: Vec<_> = list.into_iter().collect();
    assert_eq!(vec, vec![1, 2, 3, 4]);
}

fn peek_next(&mut self) -> Option<&mut A>

Provides a reference to the next element, without changing the iterator.

Examples

fn main() { use std::collections::LinkedList; let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); let mut it = list.iter_mut(); assert_eq!(it.next().unwrap(), &1); assert_eq!(it.peek_next().unwrap(), &2); // We just peeked at 2, so it was not consumed from the iterator. assert_eq!(it.next().unwrap(), &2); }
use std::collections::LinkedList;

let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect();

let mut it = list.iter_mut();
assert_eq!(it.next().unwrap(), &1);
assert_eq!(it.peek_next().unwrap(), &2);
// We just peeked at 2, so it was not consumed from the iterator.
assert_eq!(it.next().unwrap(), &2);

Trait Implementations

impl<'a, A> Iterator for IterMut<'a, A>

type Item = &'a mut A

fn next(&mut self) -> Option<&'a mut A>

fn size_hint(&self) -> (usize, Option<usize>)

fn size_hint(&self) -> (usize, Option<usize>)

impl<'a, A> DoubleEndedIterator for IterMut<'a, A>

fn next_back(&mut self) -> Option<&'a mut A>

impl<'a, A> ExactSizeIterator for IterMut<'a, A>

fn len(&self) -> usize