Struct pyinrs::Dict

source ·
pub struct Dict<K, V> { /* private fields */ }

Implementations§

source§

impl<K: Ord, V> Dict<K, V>

source

pub fn new() -> Self

Makes a new, empty Dict.

source

pub fn len(&self) -> usize

Returns the number of elements in the dict.

source

pub fn is_empty(&self) -> bool

Returns true if the dict contains no elements.

source

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

Gets an iterator over the entries of the dict, sorted by key.

source

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

Returns true if the dict contains a value for the specified key.

source

pub fn get<'a>(&'a self, key: &K, default: &'a V) -> &V

Return a reference of the value for key if key is in the dick, else default value.

source

pub fn keys(&self) -> Set<K>
where K: Clone,

Return a new set of the dict’s keys.

source

pub fn values(&self) -> Set<V>
where V: Ord + Clone,

Return a new set of the dict’s values.

source

pub fn items(&self) -> Set<(K, V)>
where K: Clone, V: Ord + Clone,

Return a new set of the dict’s items.

source

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

Adds a value to the dict. Returns whether the value was newly inserted.

source

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

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

source

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

Removes the first element from the dict and returns it, if any.

source

pub fn clear(&mut self)

Clears the dict, removing all elements.

Trait Implementations§

source§

impl<K: Clone, V: Clone> Clone for Dict<K, V>

source§

fn clone(&self) -> Dict<K, V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Debug, V: Debug> Debug for Dict<K, V>

source§

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

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

impl<K: Default, V: Default> Default for Dict<K, V>

source§

fn default() -> Dict<K, V>

Returns the “default value” for a type. Read more
source§

impl<K: Display, V: Display> Display for Dict<K, V>

source§

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

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

impl<K: Ord, V, const N: usize> From<[(K, V); N]> for Dict<K, V>

source§

fn from(value: [(K, V); N]) -> Self

Converts to this type from the input type.
source§

impl<K, V> From<BTreeMap<K, V>> for Dict<K, V>

source§

fn from(value: BTreeMap<K, V>) -> Self

Converts to this type from the input type.
source§

impl<K, V> From<Dict<K, V>> for BTreeMap<K, V>

source§

fn from(value: Dict<K, V>) -> Self

Converts to this type from the input type.
source§

impl<K: Ord, V> FromIterator<(K, V)> for Dict<K, V>

source§

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

Creates a value from an iterator. Read more
source§

impl<K: Hash, V: Hash> Hash for Dict<K, V>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<K: Ord, V> Index<&K> for Dict<K, V>

§

type Output = V

The returned type after indexing.
source§

fn index(&self, key: &K) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<K: Ord, V> IndexMut<&K> for Dict<K, V>

source§

fn index_mut(&mut self, key: &K) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<K, V> IntoIterator for Dict<K, V>

§

type Item = (K, V)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: PartialEq, V: PartialEq> PartialEq for Dict<K, V>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K: Ord + Clone, V: PartialEq> PartialOrd for Dict<K, V>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<K: Eq, V: Eq> Eq for Dict<K, V>

source§

impl<K, V> StructuralPartialEq for Dict<K, V>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<K, V> Unpin for Dict<K, V>

§

impl<K, V> UnwindSafe for Dict<K, V>

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default 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>,

§

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>,

§

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.