[][src]Struct rustypy::pytypes::pydict::PyDict

pub struct PyDict<K> where
    K: Eq + Hash + PyDictKey, 
{ /* fields omitted */ }

Methods

impl<K> PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

pub fn new() -> PyDict<K>[src]

Creates an empty PyDict.

pub fn insert<V>(&mut self, k: K, v: V) -> Option<V> where
    PyArg: From<V>,
    V: From<PyArg>, 
[src]

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the module-level documentation for more.

pub fn remove<V>(&mut self, k: &K) -> Option<V> where
    V: From<PyArg>, 
[src]

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

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

pub fn get<'a, V>(&'a self, k: &K) -> Option<&'a V> where
    PyArg: AsRef<V>, 
[src]

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

pub unsafe fn from_ptr(ptr: *mut size_t) -> PyDict<K>[src]

Get a PyDict from a previously boxed PyDict.

Takes the key as type parameter K, the raw pointer to the dictionary as argument and returns a PyDict with key type K (check PyArg variants for allowed key types).

let dict = unsafe { PyDict::<u64>::from_ptr(dict) };

pub fn into_raw(self) -> *mut size_t[src]

Returns self as raw pointer. Use this method when returning a PyDict to Python.

pub fn into_hashmap<V>(self) -> HashMap<K, V> where
    V: From<PyArg>, 
[src]

Consumes self and returns a HashMap, takes one type parameter and transforms inner content to that type.

pub fn speciallized_iter<V: From<PyArg>>(self) -> IntoIter<K, V>[src]

Consume self and turn it into an iterator.

Trait Implementations

impl<K> AsRef<PyDict<K>> for PyArg where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K: Clone> Clone for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K: Debug> Debug for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K: Default> Default for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K, V> From<HashMap<K, V, RandomState>> for PyDict<K> where
    K: PyDictKey + Eq + Hash,
    PyArg: From<V>, 
[src]

impl<K> From<PyArg> for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K> From<PyDict<K>> for PyArg where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K, V> FromIterator<(K, V)> for PyDict<K> where
    K: PyDictKey + Eq + Hash,
    PyArg: From<V>, 
[src]

impl<K: PartialEq> PartialEq<PyDict<K>> for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

impl<K> StructuralPartialEq for PyDict<K> where
    K: Eq + Hash + PyDictKey, 
[src]

Auto Trait Implementations

impl<K> RefUnwindSafe for PyDict<K> where
    K: RefUnwindSafe

impl<K> !Send for PyDict<K>

impl<K> !Sync for PyDict<K>

impl<K> Unpin for PyDict<K> where
    K: Unpin

impl<K> UnwindSafe for PyDict<K> where
    K: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.