Struct phf::OrderedSet

source ·
pub struct OrderedSet<T: 'static> { /* private fields */ }
Expand description

An order-preserving immutable set constructed at compile time.

Unlike a Set, iteration order is guaranteed to match the definition order.

Note

The fields of this struct are public so that they may be initialized by the phf_ordered_set! macro and code generation. They are subject to change at any time and should never be accessed directly.

Implementations§

source§

impl<T> OrderedSet<T>

source

pub const fn len(&self) -> usize

Returns the number of elements in the OrderedSet.

source

pub const fn is_empty(&self) -> bool

Returns true if the OrderedSet contains no elements.

source

pub fn get_key<U>(&self, key: &U) -> Option<&T>where U: Eq + PhfHash + ?Sized, T: PhfBorrow<U>,

Returns a reference to the set’s internal static instance of the given key.

This can be useful for interning schemes.

source

pub fn get_index<U>(&self, key: &U) -> Option<usize>where U: Eq + PhfHash + ?Sized, T: PhfBorrow<U>,

Returns the index of the key within the list used to initialize the ordered set.

source

pub fn index(&self, index: usize) -> Option<&T>

Returns a reference to the key at an index within the list used to initialize the ordered set. See .get_index(key).

source

pub fn contains<U>(&self, value: &U) -> boolwhere U: Eq + PhfHash + ?Sized, T: PhfBorrow<U>,

Returns true if value is in the OrderedSet.

source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the values in the set.

Values are returned in the same order in which they were defined.

source§

impl<T> OrderedSet<T>where T: Eq + PhfHash + PhfBorrow<T>,

source

pub fn is_disjoint(&self, other: &OrderedSet<T>) -> bool

Returns true if other shares no elements with self.

source

pub fn is_subset(&self, other: &OrderedSet<T>) -> bool

Returns true if other contains all values in self.

source

pub fn is_superset(&self, other: &OrderedSet<T>) -> bool

Returns true if self contains all values in other.

Trait Implementations§

source§

impl<T> Debug for OrderedSet<T>where T: Debug,

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, T> IntoIterator for &'a OrderedSet<T>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for OrderedSet<T>where T: RefUnwindSafe,

§

impl<T> Send for OrderedSet<T>where T: Sync,

§

impl<T> Sync for OrderedSet<T>where T: Sync,

§

impl<T> Unpin for OrderedSet<T>

§

impl<T> UnwindSafe for OrderedSet<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.