Container traits

Trait Container

A trait to represent the abstract idea of a container. The only concrete knowledge known is the number of elements contained within.

Method len

fn len(&self) -> uint

Return the number of elements in the container

Method is_empty

fn is_empty(&self) -> bool

Return true if the container contains no elements

Trait Map

A map is a key-value store where values may be looked up by their keys. This trait provides basic operations to operate on these stores.

Method find

fn find<'a>(&'a self, key: &K) -> Option<&'a V>

Return a reference to the value corresponding to the key

Method contains_key

fn contains_key(&self, key: &K) -> bool

Return true if the map contains a value for the specified key

Trait Mutable

A trait to represent mutable containers

Method clear

fn clear(&mut self)

Clear the container, removing all values.

Trait MutableMap

This trait provides basic operations to modify the contents of a map.

Method insert

fn insert(&mut self, key: K, value: V) -> bool

Insert a key-value pair into the map. An existing value for a key is replaced by the new value. Return true if the key did not already exist in the map.

Method remove

fn remove(&mut self, key: &K) -> bool

Remove a key-value pair from the map. Return true if the key was present in the map, otherwise false.

Method swap

fn swap(&mut self, k: K, v: V) -> Option<V>

Insert a key-value pair from the map. If the key already had a value present in the map, that value is returned. Otherwise None is returned.

Method pop

fn pop(&mut self, k: &K) -> Option<V>

Removes a key from the map, returning the value at the key if the key was previously in the map.

Method find_mut

fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>

Return a mutable reference to the value corresponding to the key

Trait MutableSet

This trait represents actions which can be performed on sets to mutate them.

Method insert

fn insert(&mut self, value: T) -> bool

Add a value to the set. Return true if the value was not already present in the set.

Method remove

fn remove(&mut self, value: &T) -> bool

Remove a value from the set. Return true if the value was present in the set.

Trait Set

A set is a group of objects which are each distinct from one another. This trait represents actions which can be performed on sets to iterate over them.

Method contains

fn contains(&self, value: &T) -> bool

Return true if the set contains a value

Method is_disjoint

fn is_disjoint(&self, other: &Self) -> bool

Return true if the set has no elements in common with other. This is equivalent to checking for an empty intersection.

Method is_subset

fn is_subset(&self, other: &Self) -> bool

Return true if the set is a subset of another

Method is_superset

fn is_superset(&self, other: &Self) -> bool

Return true if the set is a superset of another