Dictionary

Struct Dictionary 

Source
pub struct Dictionary<K, V>
where K: Hash + Eq,
{ /* private fields */ }

Implementations§

Source§

impl<K, V> Dictionary<K, V>
where K: Clone + Hash + PartialEq + Copy + Eq, V: Clone + Copy,

Source

pub fn new() -> Dictionary<K, V>

Examples found in repository?
examples/insert.rs (line 4)
3fn main() {
4    let mut _d: Dictionary<u8, u8> = Dictionary::new();
5    _d.insert(1, 2);
6    _d.insert(3, 4);
7
8    println!("{}", *_d.get(&3).unwrap());
9}
Source

pub fn with_capacity(size: usize) -> Dictionary<K, V>

Source

pub fn clear(&mut self)

Source

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

Source

pub fn from_vecs(key_vec: Vec<K>, value_vec: Vec<V>) -> Dictionary<K, V>

Source

pub fn from_tuples(tuples: Vec<(K, V)>) -> Dictionary<K, V>

Source

pub fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Examples found in repository?
examples/insert.rs (line 8)
3fn main() {
4    let mut _d: Dictionary<u8, u8> = Dictionary::new();
5    _d.insert(1, 2);
6    _d.insert(3, 4);
7
8    println!("{}", *_d.get(&3).unwrap());
9}
More examples
Hide additional examples
examples/from_iter.rs (line 10)
4fn main() {
5    let tuples: Vec<(u8, u8)> = vec![(1, 3), (5, 7)];
6    let _d: Dictionary<u8, u8> = Dictionary::from_iter(tuples.iter());
7    let tuples_array: Vec<(u8, [u8; 5])> = vec![(2, [3, 4, 5, 6, 7]), (8, [9, 10, 11, 12, 13])];
8    let _d_array: Dictionary<u8, [u8; 5]> = Dictionary::from_iter(tuples_array.iter());
9
10    println!("{}", *_d.get(&5).unwrap());
11    println!("{:?}", *_d_array.get(&8).unwrap());
12}
Source

pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Examples found in repository?
examples/insert.rs (line 5)
3fn main() {
4    let mut _d: Dictionary<u8, u8> = Dictionary::new();
5    _d.insert(1, 2);
6    _d.insert(3, 4);
7
8    println!("{}", *_d.get(&3).unwrap());
9}
Source

pub fn iter(&self) -> Iter<'_, K, V>

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn remove(&mut self, key: &K) -> Option<V>

Source

pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Trait Implementations§

Source§

impl<K, V> Debug for Dictionary<K, V>
where K: Display + Clone + Copy + Hash + Debug + Eq, V: Display + Clone + Copy + Debug,

Source§

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

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

impl<K, V> Display for Dictionary<K, V>
where K: Display + Clone + Copy + Hash + Eq, V: Display + Clone + Copy,

Source§

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

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

impl<K, V, X> Equivalent<X> for Dictionary<K, V>
where Dictionary<K, V>: PartialEq<X>, K: Eq + Hash,

Source§

fn equivalent(&self, other: &X) -> bool

Compare self to key and return true if they are equal.
Source§

impl<'a, K, V> FromIterator<&'a (K, V)> for Dictionary<K, V>
where K: Clone + Copy + Hash + PartialEq + Eq + 'a, V: Clone + Copy + PartialEq + 'a,

Source§

fn from_iter<T: IntoIterator<Item = &'a (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<K, V> FromIterator<(K, V)> for Dictionary<K, V>
where K: Hash + Eq + Copy, V: Copy,

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<K, V: PartialEq> PartialEq for Dictionary<K, V>
where K: Hash + Eq + PartialEq,

Source§

fn eq(&self, other: &Dictionary<K, V>) -> bool

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

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<K, V> StructuralPartialEq for Dictionary<K, V>
where K: Hash + Eq,

Auto Trait Implementations§

§

impl<K, V> Freeze for Dictionary<K, V>

§

impl<K, V> RefUnwindSafe for Dictionary<K, V>

§

impl<K, V> Send for Dictionary<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Dictionary<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Dictionary<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for Dictionary<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.