Struct rustypy::pytypes::pydict::PyDict
[−]
[src]
pub struct PyDict<K> where
K: Eq + Hash + PyDictKey, { /* fields omitted */ }
Methods
impl<K> PyDict<K> where
K: Eq + Hash + PyDictKey,
[src]
K: Eq + Hash + PyDictKey,
fn new() -> PyDict<K>
Creates an empty PyDict.
fn insert<V>(&mut self, k: K, v: V) -> Option<V> where
PyArg: From<V>,
V: From<PyArg>,
PyArg: From<V>,
V: From<PyArg>,
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.
fn remove<V>(&mut self, k: &K) -> Option<V> where
V: From<PyArg>,
V: From<PyArg>,
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.
fn get<'a, V>(&'a mut self, k: &K) -> Option<V> where
V: From<&'a PyArg>,
V: From<&'a PyArg>,
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.
unsafe fn from_ptr(ptr: *mut size_t) -> PyDict<K>
Get a PyDict from a previously boxed PyDict.
Takes two type parameters: - one corresponding to the key type (check PyArg variants) - and PyArg, corresponding to the value type
And a PyDict as a raw *mut size_t pointer.
let dict = unsafe { PyDict::<u64>::from_ptr(dict) };
fn as_ptr(self) -> *mut size_t
Returns self as raw pointer. Use this method when returning a PyTuple to Python.
fn into_hashmap<V>(self) -> HashMap<K, V> where
V: From<PyArg>,
V: From<PyArg>,
Consumes self and returns a HashMap, takes one type parameter and transforms inner content to that type.
fn into_iter<V: From<PyArg>>(self) -> IntoIter<K, V>
Consume self and turn it into an iterator.
Trait Implementations
impl<K: Clone> Clone for PyDict<K> where
K: Eq + Hash + PyDictKey,
[src]
K: Eq + Hash + PyDictKey,
fn clone(&self) -> PyDict<K>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<K: Debug> Debug for PyDict<K> where
K: Eq + Hash + PyDictKey,
[src]
K: Eq + Hash + PyDictKey,
impl<K: PartialEq> PartialEq for PyDict<K> where
K: Eq + Hash + PyDictKey,
[src]
K: Eq + Hash + PyDictKey,
fn eq(&self, __arg_0: &PyDict<K>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PyDict<K>) -> bool
This method tests for !=
.
impl<K, V> FromIterator<(K, V)> for PyDict<K> where
K: PyDictKey + Eq + Hash,
PyArg: From<V>,
[src]
K: PyDictKey + Eq + Hash,
PyArg: From<V>,
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<K, V> From<HashMap<K, V>> for PyDict<K> where
K: PyDictKey + Eq + Hash,
PyArg: From<V>,
[src]
K: PyDictKey + Eq + Hash,
PyArg: From<V>,
impl<K> From<PyArg> for PyDict<K> where
K: Eq + Hash + PyDictKey,
[src]
K: Eq + Hash + PyDictKey,