Struct non_empty_collections::index_set::NonEmptyIndexSet [−][src]
pub struct NonEmptyIndexSet<K, S = RandomState> { /* fields omitted */ }
A wrapper around ::indexmap::IndexSet
that is guaranteed to have at least one element by the
Rust's type system.
Methods
impl<K> NonEmptyIndexSet<K, RandomState>
[src]
impl<K> NonEmptyIndexSet<K, RandomState>
pub fn new(first: K) -> Self
[src]
pub fn new(first: K) -> Self
Creates a set with a default hasher.
pub fn with_capacity(first: K, capacity: usize) -> Self
[src]
pub fn with_capacity(first: K, capacity: usize) -> Self
Creates a set with a given capacity.
pub fn from_iterator(
i: impl IntoIterator<Item = K>
) -> Result<Self, Error> where
K: Hash + Eq,
[src]
pub fn from_iterator(
i: impl IntoIterator<Item = K>
) -> Result<Self, Error> where
K: Hash + Eq,
Creates a set from a given iterator with a default hasher.
impl<K, S> NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
[src]
impl<K, S> NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
pub fn with_hasher(first: K, hash_builder: S) -> Self
[src]
pub fn with_hasher(first: K, hash_builder: S) -> Self
Creates a set with a given hasher.
pub fn with_capacity_and_hasher(
first: K,
capacity: usize,
hash_builder: S
) -> Self
[src]
pub fn with_capacity_and_hasher(
first: K,
capacity: usize,
hash_builder: S
) -> Self
Creates a set with a given capacity.
pub fn iter(
&self
) -> impl Iterator<Item = &K>
[src]
pub fn iter(
&self
) -> impl Iterator<Item = &K>
Iterates over key-value paris of the set in an immutable way.
pub fn from_iter_with_hasher(
i: impl IntoIterator<Item = K>,
hasher: S
) -> Result<Self, Error>
[src]
pub fn from_iter_with_hasher(
i: impl IntoIterator<Item = K>,
hasher: S
) -> Result<Self, Error>
Creates a set from a given iterator with a given hasher.
pub fn get<Q>(&self, key: &Q) -> Option<&K> where
K: Borrow<Q>,
Q: Eq + Hash,
[src]
pub fn get<Q>(&self, key: &Q) -> Option<&K> where
K: Borrow<Q>,
Q: Eq + Hash,
Gets a stored key from the set.
pub fn take<Q>(&mut self, key: &Q) -> Result<Option<K>, Error> where
K: Borrow<Q>,
Q: Eq + Hash,
[src]
pub fn take<Q>(&mut self, key: &Q) -> Result<Option<K>, Error> where
K: Borrow<Q>,
Q: Eq + Hash,
Removes and returns a value from the set that is equal to a given key, if any.
An attempt to remove the last element will cause an Error
to be returned.
pub fn remove<Q>(&mut self, key: &Q) -> Result<bool, Error> where
K: Borrow<Q>,
Q: Eq + Hash,
[src]
pub fn remove<Q>(&mut self, key: &Q) -> Result<bool, Error> where
K: Borrow<Q>,
Q: Eq + Hash,
Removes a value from the set that is equal to a given key, if any. Returns true
if the
value was present in the set.
An attempt to remove the last element will cause an Error
to be returned.
pub fn insert(&mut self, key: K) -> bool
[src]
pub fn insert(&mut self, key: K) -> bool
Adds a value to the set.
If there was no such a value in the set before, true
is returned.
If the value is in the set already, it remains unchaged and false
is returned.
pub fn replace(&mut self, key: K) -> Option<K>
[src]
pub fn replace(&mut self, key: K) -> Option<K>
Replaces a value in the set with a given one. An old value is returned, if any.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the set.
Trait Implementations
impl<'de, K, S> Deserialize<'de> for NonEmptyIndexSet<K, S> where
K: Deserialize<'de>,
K: Eq + Hash,
S: BuildHasher + Default,
[src]
impl<'de, K, S> Deserialize<'de> for NonEmptyIndexSet<K, S> where
K: Deserialize<'de>,
K: Eq + Hash,
S: BuildHasher + Default,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<K, H> Serialize for NonEmptyIndexSet<K, H> where
K: Serialize,
K: Eq + Hash,
H: BuildHasher,
[src]
impl<K, H> Serialize for NonEmptyIndexSet<K, H> where
K: Serialize,
K: Eq + Hash,
H: BuildHasher,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<K: Clone, S: Clone> Clone for NonEmptyIndexSet<K, S>
[src]
impl<K: Clone, S: Clone> Clone for NonEmptyIndexSet<K, S>
fn clone(&self) -> NonEmptyIndexSet<K, S>
[src]
fn clone(&self) -> NonEmptyIndexSet<K, S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<K: Eq + Hash, S: BuildHasher> Into<IndexSet<K, S>> for NonEmptyIndexSet<K, S>
[src]
impl<K: Eq + Hash, S: BuildHasher> Into<IndexSet<K, S>> for NonEmptyIndexSet<K, S>
impl<K, S> Debug for NonEmptyIndexSet<K, S> where
K: Eq + Hash + Debug,
S: BuildHasher,
[src]
impl<K, S> Debug for NonEmptyIndexSet<K, S> where
K: Eq + Hash + Debug,
S: BuildHasher,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<K, S> Extend<K> for NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
[src]
impl<K, S> Extend<K> for NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
fn extend<T: IntoIterator<Item = K>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = K>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
impl<K, S> IntoIterator for NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
[src]
impl<K, S> IntoIterator for NonEmptyIndexSet<K, S> where
K: Eq + Hash,
S: BuildHasher,
Auto Trait Implementations
impl<K, S> Send for NonEmptyIndexSet<K, S> where
K: Send,
S: Send,
impl<K, S> Send for NonEmptyIndexSet<K, S> where
K: Send,
S: Send,
impl<K, S> Sync for NonEmptyIndexSet<K, S> where
K: Sync,
S: Sync,
impl<K, S> Sync for NonEmptyIndexSet<K, S> where
K: Sync,
S: Sync,