OrderedAssociated

Struct OrderedAssociated 

Source
pub struct OrderedAssociated<K, V> { /* private fields */ }
Expand description

An ordered, deduplicated slice of items each paired with some associated value.

Like Ordered, the contained Vec<(K, V)> is sealed after construction and cannot be modified. To unseal the inner Vec<(K, V)>, use the Into<Vec<(K, V)>> impl.

Consumers that only need the ordered keys can treat an OrderedAssociated as an Ordered through deref coercions.

Implementations§

Source§

impl<K, V> OrderedAssociated<K, V>

Source

pub fn len(&self) -> usize

Returns the number of entries in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map is empty.

Source

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

Returns a key by index, if it exists.

Source

pub fn position(&self, key: &K) -> Option<usize>
where K: Ord,

Returns the position of the provided key, if it exists.

Source

pub fn keys(&self) -> &Ordered<K>

Returns the ordered keys as an Ordered reference.

Source

pub fn into_keys(self) -> Ordered<K>

Consumes the map and returns the ordered keys.

Source

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

Returns the associated value at index, if it exists.

Source

pub fn get_value(&self, key: &K) -> Option<&V>
where K: Ord,

Returns the associated value for key, if it exists.

Source

pub fn values(&self) -> &[V]

Returns the associated values.

Source

pub fn iter_pairs(&self) -> impl Iterator<Item = (&K, &V)>

Returns a zipped iterator over keys and values.

Source

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

Returns an iterator over the ordered keys.

Methods from Deref<Target = Ordered<K>>§

Source

pub fn len(&self) -> usize

Returns the size of the ordered collection.

Source

pub fn is_empty(&self) -> bool

Returns true if the collection is empty.

Source

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

Returns an item by index, if it exists.

Source

pub fn position(&self, item: &T) -> Option<usize>
where T: Ord,

Returns the position of a given item in the collection, if it exists.

Source

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

Returns an iterator over the items in the collection.

Trait Implementations§

Source§

impl<K, V> AsRef<[K]> for OrderedAssociated<K, V>

Source§

fn as_ref(&self) -> &[K]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K, V> AsRef<Ordered<K>> for OrderedAssociated<K, V>

Source§

fn as_ref(&self) -> &Ordered<K>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K: Clone, V: Clone> Clone for OrderedAssociated<K, V>

Source§

fn clone(&self) -> OrderedAssociated<K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug, V: Debug> Debug for OrderedAssociated<K, V>

Source§

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

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

impl<K, V> Deref for OrderedAssociated<K, V>

Source§

type Target = Ordered<K>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<K: EncodeSize, V: EncodeSize> EncodeSize for OrderedAssociated<K, V>

Source§

fn encode_size(&self) -> usize

Returns the encoded size of this value (in bytes).
Source§

impl<K: Ord + Clone, V: Clone> From<&[(K, V)]> for OrderedAssociated<K, V>

Source§

fn from(items: &[(K, V)]) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord + Clone, V: Clone, const N: usize> From<&[(K, V); N]> for OrderedAssociated<K, V>

Source§

fn from(items: &[(K, V); N]) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V, const N: usize> From<[(K, V); N]> for OrderedAssociated<K, V>

Source§

fn from(items: [(K, V); N]) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V> From<OrderedAssociated<K, V>> for Vec<(K, V)>

Source§

fn from(wrapped: OrderedAssociated<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V> From<Vec<(K, V)>> for OrderedAssociated<K, V>

Source§

fn from(items: Vec<(K, V)>) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V> FromIterator<(K, V)> for OrderedAssociated<K, V>

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<K: Hash, V: Hash> Hash for OrderedAssociated<K, V>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, K, V> IntoIterator for &'a OrderedAssociated<K, V>

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Zip<Iter<'a, K>, Iter<'a, V>>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V> IntoIterator for OrderedAssociated<K, V>

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = OrderedAssociatedIntoIter<K, V>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: PartialEq, V: PartialEq> PartialEq for OrderedAssociated<K, V>

Source§

fn eq(&self, other: &OrderedAssociated<K, V>) -> 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<K: Read, V: Read> Read for OrderedAssociated<K, V>

Source§

type Cfg = (RangeCfg<usize>, <K as Read>::Cfg, <V as Read>::Cfg)

The Cfg type parameter allows passing configuration during the read process. This is crucial for safely decoding untrusted data, for example, by providing size limits for collections or strings. Read more
Source§

fn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Reads a value from the buffer using the provided configuration cfg. Read more
Source§

impl<K: Write, V: Write> Write for OrderedAssociated<K, V>

Source§

fn write(&self, buf: &mut impl BufMut)

Writes the binary representation of self to the provided buffer buf. Read more
Source§

impl<K: Eq, V: Eq> Eq for OrderedAssociated<K, V>

Source§

impl<K, V> StructuralPartialEq for OrderedAssociated<K, V>

Auto Trait Implementations§

§

impl<K, V> Freeze for OrderedAssociated<K, V>

§

impl<K, V> RefUnwindSafe for OrderedAssociated<K, V>

§

impl<K, V> Send for OrderedAssociated<K, V>
where V: Send, K: Send,

§

impl<K, V> Sync for OrderedAssociated<K, V>
where V: Sync, K: Sync,

§

impl<K, V> Unpin for OrderedAssociated<K, V>
where V: Unpin, K: Unpin,

§

impl<K, V> UnwindSafe for OrderedAssociated<K, V>
where V: UnwindSafe, K: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Decode for T
where T: Read,

Source§

fn decode_cfg(buf: impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Decodes a value from buf using cfg, ensuring the entire buffer is consumed. Read more
Source§

impl<T> Encode for T
where T: Write + EncodeSize,

Source§

fn encode(&self) -> BytesMut

Encodes self into a new BytesMut buffer. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Codec for T
where T: Encode + Decode,