Struct OrderedSet

Source
pub struct OrderedSet<K: 'static> { /* private fields */ }
Expand description

An order-preserving set which can be constructed at compile time.

“Order-preserving” means iteration order is guaranteed to match the definition order.

Implementations§

Source§

impl<K> OrderedSet<K>

Source

pub const fn new() -> Self

Create an set map.

Source

pub const fn len(&self) -> usize

Returns the number of entries in the map.

Source

pub const fn is_empty(&self) -> bool

Returns true if the map is empty.

Source

pub fn get<T: ?Sized>(&self, key: &T) -> Option<&K>
where K: PhfKeyProxy<T>,

Returns a reference to the value that key maps to.

Source

pub fn contains<T: ?Sized>(&self, key: &T) -> bool
where K: PhfKeyProxy<T>,

Determines if key is in the OrderedMap.

Source

pub fn get_index<T: ?Sized>(&self, key: &T) -> Option<usize>
where K: PhfKeyProxy<T>,

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

Source

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

Returns references to both the key and values at an index within the list used to initialize the ordered map. See .get_index(key).

Source

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

Returns an iterator over the values in the set.

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

Source

pub fn is_disjoint(&self, other: &OrderedSet<K>) -> bool
where K: PhfKeyProxy<K>,

Returns true if other shares no elements with self.

Source

pub fn is_subset(&self, other: &OrderedSet<K>) -> bool
where K: PhfKeyProxy<K>,

Returns true if other contains all values in self.

Source

pub fn is_superset(&self, other: &OrderedSet<K>) -> bool
where K: PhfKeyProxy<K>,

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<K> Default for OrderedSet<K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

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
Source§

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

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Auto Trait Implementations§

§

impl<K> Freeze for OrderedSet<K>

§

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

§

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

§

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

§

impl<K> Unpin for OrderedSet<K>

§

impl<K> UnwindSafe for OrderedSet<K>
where K: 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, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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.