SinglyIterableMut

Trait SinglyIterableMut 

Source
pub trait SinglyIterableMut<T, M, P>: HasSinglyEndsMut<T, M, P>
where M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>, Self: Sized,
{ // Provided methods fn iter_mut<'a>(&'a mut self) -> SinglyIterMut<'a, T, P> where M: 'a { ... } fn iter_mut_from<'a>( &'a mut self, idx: &SinglyIdx<T>, ) -> SinglyIterMut<'a, T, P> where M: 'a { ... } }
Expand description

Iterator methods for Singly linked lists.

Provided Methods§

Source

fn iter_mut<'a>(&'a mut self) -> SinglyIterMut<'a, T, P>
where M: 'a,

Returns a double-ended iterator of mutable references to elements of the list from front to back.

§Examples
use orx_linked_list::*;

let mut list = SinglyList::new();

list.push_front(2);
list.push_front(1);
list.push_front(0);
assert!(list.eq_to_iter_vals([0, 1, 2]));

for x in list.iter_mut() {
    *x += 40;
}

assert!(list.eq_to_iter_vals([40, 41, 42]));
Source

fn iter_mut_from<'a>( &'a mut self, idx: &SinglyIdx<T>, ) -> SinglyIterMut<'a, T, P>
where M: 'a,

Creates a mutable forward iterator:

  • from the node with the given idx
  • to the back of the list.
§Panics

Panics if the index is invalid; i.e., idx_err does not return None.

§Example
use orx_linked_list::*;

let mut list = SinglyList::new();

list.push_front(3);
list.push_front(2);
let idx = list.push_front(1);
list.push_front(0);

assert!(list.eq_to_iter_vals([0, 1, 2, 3]));

for x in list.iter_mut_from(&idx) {
    *x += 10;
}

assert!(list.eq_to_iter_vals([0, 11, 12, 13]));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<L, T, M, P> SinglyIterableMut<T, M, P> for L
where L: HasSinglyEndsMut<T, M, P>, M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,