Struct collections::binary_heap::Hole [] [src]

struct Hole<'a, T: 'a> {
    data: &'a mut [T],
    elt: Option<T>,
    pos: usize,
}

Hole represents a hole in a slice i.e. an index without valid value (because it was moved from or duplicated). In drop, Hole will restore the slice by filling the hole position with the value that was originally removed.

Fields

data
elt

elt is always Some from new until drop.

pos

Methods

impl<'a, T> Hole<'a, T>

fn new(data: &'a mut [T], pos: usize) -> Self

Create a new Hole at index pos.

fn pos(&self) -> usize

fn element(&self) -> &T

Return a reference to the element removed

unsafe fn get(&self, index: usize) -> &T

Return a reference to the element at index.

Panics if the index is out of bounds.

Unsafe because index must not equal pos.

unsafe fn move_to(&mut self, index: usize)

Move hole to new location

Unsafe because index must not equal pos.

Trait Implementations

impl<'a, T> Drop for Hole<'a, T>

fn drop(&mut self)