Struct Hole

pub(in ::collections::binary_heap) struct Hole<'a, T: 'a> { pub(in ::collections::binary_heap) data: &'a mut [T], pub(in ::collections::binary_heap) elt: ManuallyDrop<T>, pub(in ::collections::binary_heap) 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: &'a mut [T]
elt: ManuallyDrop<T>
pos: usize

Implementations

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

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

Creates a new Hole at index pos.

Unsafe because pos must be within the data slice.

fn pos(&self) -> usize
fn element(&self) -> &T

Returns a reference to the element removed.

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

Returns a reference to the element at index.

Unsafe because index must be within the data slice and not equal to pos.

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

Move hole to new location

Unsafe because index must be within the data slice and not equal to pos.

Trait Implementations

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

fn drop(&mut self)

Auto Trait Implementations

impl<'a, T> !UnwindSafe for Hole<'a, T>

impl<'a, T> Freeze for Hole<'a, T> where &'a mut [T]: Freeze, ManuallyDrop<T>: Freeze,

impl<'a, T> RefUnwindSafe for Hole<'a, T> where &'a mut [T]: RefUnwindSafe, ManuallyDrop<T>: RefUnwindSafe,

impl<'a, T> Send for Hole<'a, T> where &'a mut [T]: Send, ManuallyDrop<T>: Send,

impl<'a, T> Sync for Hole<'a, T> where &'a mut [T]: Sync, ManuallyDrop<T>: Sync,

impl<'a, T> Unpin for Hole<'a, T> where &'a mut [T]: Unpin, ManuallyDrop<T>: Unpin,

impl<'a, T> UnsafeUnpin for Hole<'a, T> where &'a mut [T]: UnsafeUnpin, ManuallyDrop<T>: UnsafeUnpin,

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Hole<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Hole<'a, T> where T: ?Sized,

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

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

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Hole<'a, T> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

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

impl<T, U> Into<U> for Hole<'a, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for Hole<'a, T> where U: Into<T>,

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

impl<T, U> TryInto<U> for Hole<'a, T> where U: TryFrom<T>,

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