Ordered

Struct Ordered 

Source
pub struct Ordered<T>(/* private fields */);
Expand description

An ordered, deduplicated slice of items.

After construction, the contained Vec<T> is sealed and cannot be modified. To unseal the inner Vec<T>, use the Into<Vec<T>> impl.

Implementations§

Source§

impl<T> Ordered<T>

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<T> AsRef<[T]> for Ordered<T>

Source§

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

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<T: Clone> Clone for Ordered<T>

Source§

fn clone(&self) -> Ordered<T>

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<T: Debug> Debug for Ordered<T>

Source§

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

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

impl<T: Display> Display for Ordered<T>

Source§

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

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

impl<T: EncodeSize> EncodeSize for Ordered<T>

Source§

fn encode_size(&self) -> usize

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

impl<T: Ord + Clone> From<&[T]> for Ordered<T>

Source§

fn from(items: &[T]) -> Self

Converts to this type from the input type.
Source§

impl<T: Ord + Clone, const N: usize> From<&[T; N]> for Ordered<T>

Source§

fn from(items: &[T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T: Ord, const N: usize> From<[T; N]> for Ordered<T>

Source§

fn from(items: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T: Ord> From<Ordered<T>> for Vec<T>

Source§

fn from(set: Ordered<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Ord> From<Vec<T>> for Ordered<T>

Source§

fn from(items: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Ord> FromIterator<T> for Ordered<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for Ordered<T>

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<T> Index<Range<usize>> for Ordered<T>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<usize> for Ordered<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a Ordered<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) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for Ordered<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

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<T: Ord> Ord for Ordered<T>

Source§

fn cmp(&self, other: &Ordered<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Ordered<T>

Source§

fn eq(&self, other: &Ordered<T>) -> 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: PartialOrd> PartialOrd for Ordered<T>

Source§

fn partial_cmp(&self, other: &Ordered<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Read> Read for Ordered<T>

Source§

type Cfg = (RangeCfg<usize>, <T 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<T: Write> Write for Ordered<T>

Source§

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

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

impl<T: Eq> Eq for Ordered<T>

Source§

impl<T> StructuralPartialEq for Ordered<T>

Auto Trait Implementations§

§

impl<T> Freeze for Ordered<T>

§

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

§

impl<T> Send for Ordered<T>
where T: Send,

§

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

§

impl<T> Unpin for Ordered<T>
where T: Unpin,

§

impl<T> UnwindSafe for Ordered<T>
where T: 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<X, U> DecodeRangeExt<X> for U
where X: IsUnit, U: Decode<Cfg = (RangeCfg<usize>, X)>,

Source§

fn decode_range( buf: impl Buf, range: impl RangeBounds<usize>, ) -> Result<Self, Error>

Decodes a value using only a range configuration. 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<X, U> ReadRangeExt<X> for U
where X: IsUnit, U: Read<Cfg = (RangeCfg<usize>, X)>,

Source§

fn read_range( buf: &mut impl Buf, range: impl RangeBounds<usize>, ) -> Result<Self, Error>

Reads a value using only a range configuration. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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,