Struct json_api::value::collections::set::Set
[−]
[src]
pub struct Set<T: Eq + Hash = Key> { /* fields omitted */ }
A hash set implemented as a Map
where the value is ()
.
Methods
impl<T: Eq + Hash> Set<T>
[src]
fn new() -> Self
[src]
fn with_capacity(capacity: usize) -> Self
[src]
Creates a new empty Set
, with specified capacity.
Example
let mut set = Set::with_capacity(2); set.insert("x"); set.insert("y"); // The next insert will likely require reallocation... set.insert("z");
fn capacity(&self) -> usize
[src]
Returns the number of elements the set can hold without reallocating.
Example
let set = Set::<Key>::with_capacity(2); assert!(set.capacity() >= 2);
fn clear(&mut self)
[src]
Clears the set, removing all elements. Keeps the allocated memory for reuse.
Example
let mut set = Set::new(); set.insert("x"); set.clear(); assert!(set.is_empty());
fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Equivalent<T> + Hash,
[src]
Q: Equivalent<T> + Hash,
Returns true if the set contains the specified value.
Example
let mut set = Set::new(); set.insert(1); assert!(set.contains(&1)); assert!(!set.contains(&2));
fn drain(&mut self, range: RangeFull) -> Drain<T>
[src]
Clears the set, returning all elements in an iterator. Keeps the allocated memory for reuse.
Example
let mut set = Set::new(); set.insert(1); set.insert(2); for item in set.drain(..) { assert!(item == 1 || item == 2); } assert!(set.is_empty());
fn insert(&mut self, key: T) -> bool
[src]
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
Example
let mut set = Set::new(); assert_eq!(set.insert(1), true); assert_eq!(set.insert(1), false); assert_eq!(set.len(), 1);
fn is_empty(&self) -> bool
[src]
Returns true if the set does not contain any elements.
Example
let mut set = Set::new(); assert!(set.is_empty()); set.insert("x"); assert!(!set.is_empty());
fn iter(&self) -> Iter<T>
[src]
Return an iterator visiting all the elements of the set in the order in which they were inserted.
Example
let mut set = Set::new(); set.insert("a"); set.insert("b"); set.insert("c"); let mut iter = set.iter(); assert_eq!(iter.next(), Some(&"a")); assert_eq!(iter.next(), Some(&"b")); assert_eq!(iter.next(), Some(&"c")); assert_eq!(iter.next(), None);
fn len(&self) -> usize
[src]
Return the number of elements in the set.
Example
let mut set = Set::new(); assert_eq!(set.len(), 0); set.insert("x"); assert_eq!(set.len(), 1);
fn remove<Q: ?Sized>(&mut self, key: &Q) -> bool where
Q: Equivalent<T> + Hash,
[src]
Q: Equivalent<T> + Hash,
Removes a value from the set. Returns true
if the value was present
in the set.
Example
let mut set = Set::new(); set.insert("x"); assert!(set.remove("x")); assert!(!set.remove("x")); assert_eq!(set.len(), 0);
fn reserve(&mut self, additional: usize)
[src]
Trait Implementations
impl<T: Clone + Eq + Hash> Clone for Set<T>
[src]
fn clone(&self) -> Set<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Eq + Eq + Hash> Eq for Set<T>
[src]
impl<T: PartialEq + Eq + Hash> PartialEq for Set<T>
[src]
fn eq(&self, __arg_0: &Set<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Set<T>) -> bool
[src]
This method tests for !=
.
impl<T: Debug + Eq + Hash> Debug for Set<T>
[src]
impl<T: Eq + Hash> Default for Set<T>
[src]
impl<T: Eq + Hash> Extend<T> for Set<T>
[src]
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more
impl<T: Eq + Hash> FromIterator<T> for Set<T>
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl<T, E> FromStr for Set<T> where
T: Eq + FromStr<Err = E> + Hash,
E: Into<Error>,
[src]
T: Eq + FromStr<Err = E> + Hash,
E: Into<Error>,
type Err = Error
The associated error which can be returned from parsing.
fn from_str(value: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl<T: Eq + Hash> IntoIterator for Set<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, T: Eq + Hash> IntoIterator for &'a Set<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'de, T> Deserialize<'de> for Set<T> where
T: Deserialize<'de> + Eq + Hash + 'de,
[src]
T: Deserialize<'de> + Eq + Hash + 'de,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq + Hash + Serialize> Serialize for Set<T>
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more