Enum OccupiedEntryRef

Source
pub enum OccupiedEntryRef<'a, T: BiHashItem> {
    Unique(&'a T),
    NonUnique {
        by_key1: Option<&'a T>,
        by_key2: Option<&'a T>,
    },
}
Expand description

A view into an occupied entry in a BiHashMap.

Returned by OccupiedEntry::get.

Variants§

§

Unique(&'a T)

All keys point to the same entry.

§

NonUnique

The keys point to different entries, or some keys are not present.

At least one of by_key1 and by_key2 is Some.

Fields

§by_key1: Option<&'a T>

The value fetched by the first key.

§by_key2: Option<&'a T>

The value fetched by the second key.

Implementations§

Source§

impl<'a, T: BiHashItem> OccupiedEntryRef<'a, T>

Source

pub fn is_unique(&self) -> bool

Returns true if the entry is unique.

Since BiHashMap is keyed by two keys, it’s possible for OccupiedEntry to match up to two separate items. This function returns true if the entry is unique, meaning all keys point to exactly one item.

Source

pub fn is_non_unique(&self) -> bool

Returns true if the OccupiedEntryRef represents more than one item, or if some keys are not present.

Source

pub fn as_unique(&self) -> Option<&'a T>

Returns a reference to the value if it is unique.

Source

pub fn by_key1(&self) -> Option<&'a T>

Returns a reference to the value fetched by the first key.

Source

pub fn by_key2(&self) -> Option<&'a T>

Returns a reference to the value fetched by the second key.

Trait Implementations§

Source§

impl<'a, T: Debug + BiHashItem> Debug for OccupiedEntryRef<'a, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for OccupiedEntryRef<'a, T>

§

impl<'a, T> RefUnwindSafe for OccupiedEntryRef<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for OccupiedEntryRef<'a, T>
where T: Sync,

§

impl<'a, T> Sync for OccupiedEntryRef<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for OccupiedEntryRef<'a, T>

§

impl<'a, T> UnwindSafe for OccupiedEntryRef<'a, T>
where T: RefUnwindSafe,

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, 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.