1.0.0[−][src]Struct alloc::collections::linked_list::IterMut
A mutable iterator over the elements of a LinkedList
.
This struct
is created by the iter_mut
method on LinkedList
. See its
documentation for more.
Methods
impl<'_, T> IterMut<'_, T>
[src][−]
pub fn insert_next(&mut self, element: T)
[src][−]
🔬 This is a nightly-only experimental API. (linked_list_extras
#27794)
this is probably better handled by a cursor type -- we'll see
Inserts the given element 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]); }
pub fn peek_next(&mut self) -> Option<&mut T>
[src][−]
🔬 This is a nightly-only experimental API. (linked_list_extras
#27794)
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);
Trait Implementations
impl<'_, T: Send> Send for IterMut<'_, T>
[src]
impl<'_, T: Sync> Sync for IterMut<'_, T>
[src]
impl<'_, T: Debug> Debug for IterMut<'_, T>
1.17.0[src][+]
impl<'_, T> FusedIterator for IterMut<'_, T>
1.26.0[src]
impl<'_, T> ExactSizeIterator for IterMut<'_, T>
[src][+]
impl<'a, T> DoubleEndedIterator for IterMut<'a, T>
[src][+]
impl<'a, T> Iterator for IterMut<'a, T>
[src][+]
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src][+]
I: Iterator,
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> From<T> for T
[src][+]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,