[][src]Struct vecrem::Entry

pub struct Entry<'a, 'rem, T> { /* fields omitted */ }

Vec entry.

Entry allows you to remove, read or mutate the element behind it.

The only way to get this struct is to call Removing::next method.

forget behavior

When Entry destructor (drop) is not runned (this can be achieved via mem::forget, ManuallyDrop, etc) the entry is not skiped and the next call to Removing::next returns the same entry.

use core::mem;
use vecrem::VecExt;

let mut vec = vec![1, 2, 3];
{
    let mut rem = vec.removing();

    let a = rem.next().unwrap();
    assert_eq!(a.value(), &1);
    mem::forget(a);

    let b = rem.next().unwrap();
    assert_eq!(b.value(), &1);
    mem::forget(b);
}
assert_eq!(vec, [1, 2, 3]);

Implementations

impl<T> Entry<'_, '_, T>[src]

pub fn remove(self) -> T[src]

Remove element behind this entry.

pub fn value(&self) -> &T[src]

Get access to the element behind this entry.

pub fn value_mut(&mut self) -> &mut T[src]

Get unique access to the element behind this entry.

pub fn peek_next(&mut self) -> Option<&mut T>[src]

Get unique access to the element after the element behind this entry.

Returns None if this entry corresponds to the last item in the vec.

Trait Implementations

impl<T> Drop for Entry<'_, '_, T>[src]

Auto Trait Implementations

impl<'a, 'rem, T> Send for Entry<'a, 'rem, T> where
    T: Send
[src]

impl<'a, 'rem, T> Sync for Entry<'a, 'rem, T> where
    T: Sync
[src]

impl<'a, 'rem, T> Unpin for Entry<'a, 'rem, T> where
    'rem: 'a, 
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.