Set

Struct Set 

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

An ordered, deduplicated collection of items.

Implementations§

Source§

impl<T: Ord> Set<T>

Source

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

Creates a new Set from an iterator, removing duplicates.

Unlike FromIterator and From, this method tolerates duplicate items by silently discarding them.

Source§

impl<T> Set<T>

Source

pub const fn len(&self) -> usize

Returns the size of the ordered collection.

Source

pub const 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 Set<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<Set<K>> for BiMap<K, V>

Source§

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

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

impl<K, V> AsRef<Set<K>> for Map<K, V>

Source§

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

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

impl<T: Clone> Clone for Set<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Set<T>

Source§

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

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

impl<T> Default for Set<T>

Source§

fn default() -> Self

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

impl<T: Display> Display for Set<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 Set<T>

Source§

fn encode_size(&self) -> usize

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

impl<T> From<Set<T>> for Vec<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Set<T>

Source§

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

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

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 Set<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 Set<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 Set<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 Set<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 Set<T>

Source§

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

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

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

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

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

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

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 Set<T>

Source§

fn eq(&self, other: &Set<T>) -> bool

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

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 Set<T>

Source§

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

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

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

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

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§

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

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

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

Source§

type Item = T

The type of items in this set.
Source§

fn quorum(&self) -> u32

Returns the quorum value (2f+1) for this participant set. Read more
Source§

fn max_faults(&self) -> u32

Returns the maximum number of faults (f) tolerated by this participant set. Read more
Source§

fn key(&self, index: u32) -> Option<&Self::Item>

Returns the participant key at the given index.
Source§

fn index(&self, key: &Self::Item) -> Option<u32>

Returns the index for the given participant key, if present. Read more
Source§

impl<T: Read + Ord> Read for Set<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: Ord + Clone> TryFrom<&[T]> for Set<T>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(items: &[T]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(items: &[T; N]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Ord, const N: usize> TryFrom<[T; N]> for Set<T>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(items: [T; N]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Ord> TryFrom<Vec<T>> for Set<T>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(items: Vec<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Ord> TryFromIterator<T> for Set<T>

Source§

fn try_from_iter<I: IntoIterator<Item = T>>( iter: I, ) -> Result<Self, Self::Error>

Attempts to create a Set from an iterator.

Returns an error if there are duplicate items.

Source§

type Error = Error

The error type returned when construction fails.
Source§

impl<T: Write> Write for Set<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 Set<T>

Source§

impl<T> StructuralPartialEq for Set<T>

Auto Trait Implementations§

§

impl<T> Freeze for Set<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Set<T>
where T: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

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,