Trait eclectic::set::Set
[−]
[src]
pub trait Set<Q: ?Sized = Self::Item>: Base { fn get(&self, item: &Q) -> Option<&Self::Item>; fn take(&mut self, item: &Q) -> Option<Self::Item> where Self: AddRemove; fn contains(&self, item: &Q) -> bool { ... } fn remove(&mut self, item: &Q) -> bool where Self: AddRemove { ... } }
A set.
A set is a collection that prohibits duplicate items according to some criteria.
The type parameter Q
represents an "equivalence" type that can be used to look up items
in the set. For example, given a Set<Item = String>
, it is usually possible to look up
items using a str
. When omitted, Q
defaults to Self::Item
.
Required Methods
fn get(&self, item: &Q) -> Option<&Self::Item>
Returns a reference to the item in the set that is equivalent to the given item.
Returns None
if the set contains no such item.
fn take(&mut self, item: &Q) -> Option<Self::Item> where Self: AddRemove
Removes the item in the set that is equivalent to the given item and returns it.
Returns None
if the set contained no such item.
Provided Methods
fn contains(&self, item: &Q) -> bool
Checks if the set contains an item that is equivalent to the given item.
fn remove(&mut self, item: &Q) -> bool where Self: AddRemove
Removes the item in the set that is equivalent to the given item.
Returns true
if the set contained such an item, false
otherwise.