RefMutIter

Struct RefMutIter 

Source
pub struct RefMutIter<'a, I> { /* private fields */ }
Expand description

Iterator from RefMut.

§Examples

let samples = vec![1, 2, 3];
let cell = RefCell::new(samples.clone());
let mut iter = RefMutIter::new(cell.borrow_mut(), |x| x.iter_mut());
while let Some(item) = iter.next_mut() {
    *item += 1;
}
drop(iter);

let results = cell.into_inner();
let expecteds = vec![2, 3, 4];
assert_eq!(results, expecteds);

Implementations§

Source§

impl<'a, I> RefMutIter<'a, I>

Source

pub fn new<S, F>(src: RefMut<'a, S>, f: F) -> Self
where S: Any, F: Fn(&'a mut S) -> I,

Creates a new value.

Trait Implementations§

Source§

impl<'a, I: Debug> Debug for RefMutIter<'a, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I> ExactSizeRefIterator for RefMutIter<'_, I>

Source§

fn len(&self) -> usize

Returns the exact remaining length of the iterator.
Source§

fn is_empty(&self) -> bool

Returns true if the iterator is empty.
Source§

impl<'a, I, T> RefIterator for RefMutIter<'a, I>
where I: Iterator<Item = &'a mut T>, T: 'a,

Source§

type Item = T

The type of the elements being iterated over.
Source§

fn next(&mut self) -> Option<&Self::Item>

Advances the iterator and returns the next value. Read more
Source§

fn icloned(self) -> ICloned<Self>
where Self: Sized, Self::Item: Clone,

Creates an iterator that clone dynamic borrowing elements. Read more
Source§

fn iflat_map<'call, F>(self, f: F) -> IFlatMap<'call, Self, F>
where Self: Sized, F: for<'a> FnIFlatMap<&'a Self::Item>,

Creates an iterator that flattens mapped each dynamic borrowing iterators. Read more
Source§

fn imap<B, F>(self, f: F) -> IMap<Self, F>
where Self: Sized, F: FnMut(&Self::Item) -> B,

Creates an iterator that maps dynamic borrowing elements. Read more
Source§

fn eq<I>(self, other: I) -> bool
where Self: Sized, Self::Item: PartialEq<I::Item>, I: IntoRefIterator,

Determines if the elements of this is equal to those of another. Read more
Source§

impl<I> RefIteratorBase for RefMutIter<'_, I>
where I: Iterator,

Source§

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

Returns the bounds on the remaining length of the iterator. Read more
Source§

impl<'a, I, K, V> RefKvIterator for RefMutIter<'a, I>
where I: Iterator<Item = (&'a K, &'a mut V)>, K: 'a, V: 'a,

Source§

type K = K

The key type of the elements being iterated over.
Source§

type V = V

The value type of the elements being iterated over.
Source§

fn next(&mut self) -> Option<(&Self::K, &Self::V)>

Advances the iterator and returns the next key-value. Read more
Source§

fn imap<B, F>(self, f: F) -> KvIMap<Self, F>
where Self: Sized, F: FnMut(&Self::K, &Self::V) -> B,

Creates an iterator that maps dynamic borrowing elements. Read more
Source§

impl<'a, I, T> RefMutIterator for RefMutIter<'a, I>
where I: Iterator<Item = &'a mut T>, T: 'a,

Source§

fn next_mut(&mut self) -> Option<&mut Self::Item>

Advances the iterator and returns the next mutable value. Read more
Source§

impl<'a, I, K, V> RefMutKvIterator for RefMutIter<'a, I>
where I: Iterator<Item = (&'a K, &'a mut V)>, K: 'a, V: 'a,

Source§

fn next_mut(&mut self) -> Option<(&Self::K, &mut Self::V)>

Advances the iterator and returns the next mutable key-value. Read more

Auto Trait Implementations§

§

impl<'a, I> Freeze for RefMutIter<'a, I>
where I: Freeze,

§

impl<'a, I> !RefUnwindSafe for RefMutIter<'a, I>

§

impl<'a, I> !Send for RefMutIter<'a, I>

§

impl<'a, I> !Sync for RefMutIter<'a, I>

§

impl<'a, I> Unpin for RefMutIter<'a, I>
where I: Unpin,

§

impl<'a, I> !UnwindSafe for RefMutIter<'a, I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRefIterator for T
where T: RefIterator,

Source§

type Item = <T as RefIterator>::Item

The type of the elements being iterated over.
Source§

type IntoRefIter = T

Which kind of iterator are we turning this into?
Source§

fn into_ref_iter(self) -> <T as IntoRefIterator>::IntoRefIter

Creates an iterator from a value.
Source§

impl<T> IntoRefKvIterator for T
where T: RefKvIterator,

Source§

type K = <T as RefKvIterator>::K

The key type of the elements being iterated over.
Source§

type V = <T as RefKvIterator>::V

The value type of the elements being iterated over.
Source§

type IntoRefKvIter = T

Which kind of iterator are we turning this into?
Source§

fn into_ref_kv_iter(self) -> <T as IntoRefKvIterator>::IntoRefKvIter

Creates an iterator from a value.
Source§

impl<T> IntoRefMutIterator for T
where T: RefMutIterator,

Source§

type Item = <T as RefIterator>::Item

The type of the elements being iterated over.
Source§

type IntoRefMutIter = T

Which kind of iterator are we turning this into?
Source§

fn into_ref_mut_iter(self) -> <T as IntoRefMutIterator>::IntoRefMutIter

Creates an iterator from a value.
Source§

impl<T> IntoRefMutKvIterator for T

Source§

type K = <T as RefKvIterator>::K

The key type of the elements being iterated over.
Source§

type V = <T as RefKvIterator>::V

The value type of the elements being iterated over.
Source§

type IntoRefMutKvIter = T

Which kind of iterator are we turning this into?
Source§

fn into_ref_mut_kv_iter(self) -> <T as IntoRefMutKvIterator>::IntoRefMutKvIter

Creates an iterator from a value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.