Struct std::collections::linked_list::IterMut
[−]
[src]
pub struct IterMut<'a, T> where T: 'a {
list: &'a mut LinkedList<T>,
head: Rawlink<Node<T>>,
tail: Rawlink<Node<T>>,
nelem: usize,
}
An iterator over mutable references to the items of a LinkedList
.
Fields
list | |
head | |
tail | |
nelem |
Methods
impl<'a, A> IterMut<'a, A>
impl<'a, A> IterMut<'a, A>
fn insert_next(&mut self, elt: A)
Unstable (
linked_list_extras
): this is probably better handled by a cursor type -- we'll see
Inserts elt
just after the element most recently returned by .next()
.
The inserted element does not appear in the iteration.
Examples
#![feature(linked_list_extras)] 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, [1, 2, 3, 4]); }
fn peek_next(&mut self) -> Option<&mut A>
Unstable (
linked_list_extras
): this is probably better handled by a cursor type -- we'll see
Provides a reference to the next element, without changing the iterator.
Examples
#![feature(linked_list_extras)] 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);