1.0.0[−][src]Struct nom::lib::std::slice::IterMut
Mutable slice iterator.
This struct is created by the iter_mut
method on slices.
Examples
Basic usage:
// First, we declare a type which has `iter_mut` method to get the `IterMut` // struct (&[usize here]): let mut slice = &mut [1, 2, 3]; // Then, we iterate over it and increment each element value: for element in slice.iter_mut() { *element += 1; } // We now have "[2, 3, 4]": println!("{:?}", slice);
Methods
impl<'a, T> IterMut<'a, T>
[src]
[−]
impl<'a, T> IterMut<'a, T>
pub fn into_slice(self) -> &'a mut [T]
1.4.0[src]
[−]
pub fn into_slice(self) -> &'a mut [T]
1.4.0
[src]View the underlying data as a subslice of the original data.
To avoid creating &mut
references that alias, this is forced
to consume the iterator.
Examples
Basic usage:
// First, we declare a type which has `iter_mut` method to get the `IterMut` // struct (&[usize here]): let mut slice = &mut [1, 2, 3]; { // Then, we get the iterator: let mut iter = slice.iter_mut(); // We move to next element: iter.next(); // So if we print what `into_slice` method returns here, we have "[2, 3]": println!("{:?}", iter.into_slice()); } // Now let's modify a value of the slice: { // First we get back the iterator: let mut iter = slice.iter_mut(); // We change the value of the first element of the slice returned by the `next` method: *iter.next().unwrap() += 1; } // Now slice is "[2, 2, 3]": println!("{:?}", slice);
Trait Implementations
impl<'a, T> Send for IterMut<'a, T> where
T: Send,
[src]
impl<'a, T> Send for IterMut<'a, T> where
T: Send,
impl<'a, T> Debug for IterMut<'a, T> where
T: 'a + Debug,
1.9.0[src]
[+]
impl<'a, T> Debug for IterMut<'a, T> where
T: 'a + Debug,
1.9.0
[src]impl<'a, T> Iterator for IterMut<'a, T>
[src]
[+]
impl<'a, T> Iterator for IterMut<'a, T>
impl<'a, T> DoubleEndedIterator for IterMut<'a, T>
[src]
[+]
impl<'a, T> DoubleEndedIterator for IterMut<'a, T>
impl<'a, T> TrustedLen for IterMut<'a, T>
[src]
impl<'a, T> TrustedLen for IterMut<'a, T>
impl<'a, T> ExactSizeIterator for IterMut<'a, T>
[src]
[+]
impl<'a, T> ExactSizeIterator for IterMut<'a, T>
impl<'a, T> FusedIterator for IterMut<'a, T>
1.26.0[src]
impl<'a, T> FusedIterator for IterMut<'a, T>
1.26.0
[src]impl<'a, T> Sync for IterMut<'a, T> where
T: Sync,
[src]
impl<'a, T> Sync for IterMut<'a, T> where
T: Sync,
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
[−]
impl<I> IntoIterator for I where
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
[−]
fn into_iter(self) -> I
Creates an iterator from a value. Read more
impl<T, U> Into for T where
U: From<T>,
[src]
[−]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
[−]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
[−]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
[−]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
🔬 This is a nightly-only experimental API. (
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
[−]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Ifn borrow(&self) -> &T
[src]
[−]
ⓘImportant traits for &'a mut I
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
[−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
[−]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
🔬 This is a nightly-only experimental API. (
try_from
)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
[−]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Ifn borrow_mut(&mut self) -> &mut T
[src]
[−]
ⓘImportant traits for &'a mut I
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
[−]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
[−]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more