Struct pyo3::PyDict [−][src]
pub struct PyDict(_);
Represents a Python dict.
Methods
impl PyDict[src]
impl PyDictpub fn new(py: Python) -> &PyDict[src]
pub fn new(py: Python) -> &PyDictCreates a new empty dictionary.
May panic when running out of memory.
pub fn copy(&self) -> PyResult<&PyDict>[src]
pub fn copy(&self) -> PyResult<&PyDict>Return a new dictionary that contains the same key-value pairs as self.
Corresponds to dict(self) in Python.
pub fn clear(&self)[src]
pub fn clear(&self)Empty an existing dictionary of all key-value pairs.
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturn the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolCheck if dict is empty.
pub fn contains<K>(&self, key: K) -> PyResult<bool> where
K: ToBorrowedObject, [src]
pub fn contains<K>(&self, key: K) -> PyResult<bool> where
K: ToBorrowedObject, Determine if the dictionary contains the specified key.
This is equivalent to the Python expression key in self.
pub fn get_item<K>(&self, key: K) -> Option<&PyObjectRef> where
K: ToBorrowedObject, [src]
pub fn get_item<K>(&self, key: K) -> Option<&PyObjectRef> where
K: ToBorrowedObject, Gets an item from the dictionary. Returns None if the item is not present, or if an error occurs.
pub fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()> where
K: ToPyObject,
V: ToPyObject, [src]
pub fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()> where
K: ToPyObject,
V: ToPyObject, Sets an item value.
This is equivalent to the Python expression self[key] = value.
pub fn del_item<K>(&self, key: K) -> PyResult<()> where
K: ToBorrowedObject, [src]
pub fn del_item<K>(&self, key: K) -> PyResult<()> where
K: ToBorrowedObject, Deletes an item.
This is equivalent to the Python expression del self[key].
pub fn keys(&self) -> &PyList[src]
pub fn keys(&self) -> &PyListList of dict keys.
This is equivalent to the python expression list(dict.keys()).
pub fn values(&self) -> &PyList[src]
pub fn values(&self) -> &PyListList of dict values.
This is equivalent to the python expression list(dict.values()).
pub fn items(&self) -> &PyList[src]
pub fn items(&self) -> &PyListList of dict items.
This is equivalent to the python expression list(dict.items()).
pub fn iter(&self) -> PyDictIterator[src]
pub fn iter(&self) -> PyDictIteratorReturns a iterator of (key, value) pairs in this dictionary Note that it's unsafe to use when the dictionary might be changed by other python code.
Trait Implementations
impl<'a> From<&'a PyDict> for &'a PyObjectRef[src]
impl<'a> From<&'a PyDict> for &'a PyObjectRefimpl AsRef<PyObjectRef> for PyDict[src]
impl AsRef<PyObjectRef> for PyDictfn as_ref(&self) -> &PyObjectRef[src]
fn as_ref(&self) -> &PyObjectRefPerforms the conversion.
impl PyObjectWithToken for PyDict[src]
impl PyObjectWithToken for PyDictimpl ToPyPointer for PyDict[src]
impl ToPyPointer for PyDictimpl PartialEq for PyDict[src]
impl PartialEq for PyDictfn eq(&self, o: &PyDict) -> bool[src]
fn eq(&self, o: &PyDict) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl PyTypeInfo for PyDict[src]
impl PyTypeInfo for PyDicttype Type = ()
Type of objects to store in PyObject struct
type BaseType = PyObjectRef
Base class
const NAME: &'static str
NAME: &'static str = "PyDict"
Class name
const SIZE: usize
SIZE: usize = ::std::mem::size_of::<::ffi::PyObject>()
Size of the rust PyObject structure (PyObject + rust structure)
const OFFSET: isize
OFFSET: isize = 0
Type instance offset inside PyObject structure
unsafe fn type_object() -> &'static mut PyTypeObject[src]
unsafe fn type_object() -> &'static mut PyTypeObjectPyTypeObject instance for this type
fn is_instance(ptr: *mut PyObject) -> bool[src]
fn is_instance(ptr: *mut PyObject) -> boolCheck if *mut ffi::PyObject is instance of this type
const DESCRIPTION: &'static str
DESCRIPTION: &'static str = "\u{0}"
Class doc string
const FLAGS: usize
FLAGS: usize = 0
Type flags (ie PY_TYPE_FLAG_GC, PY_TYPE_FLAG_WEAKREF)
fn is_exact_instance(ptr: *mut PyObject) -> bool[src]
fn is_exact_instance(ptr: *mut PyObject) -> boolCheck if *mut ffi::PyObject is exact instance of this type
impl PyTypeObject for PyDict[src]
impl PyTypeObject for PyDictfn init_type()[src]
fn init_type()Initialize type object
fn type_object() -> Py<PyType>[src]
fn type_object() -> Py<PyType>Retrieves the type object for this Python object type.
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo, [src]
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo, Create PyRawObject which can be initialized with rust value
impl ToPyObject for PyDict[src]
impl ToPyObject for PyDictimpl ToBorrowedObject for PyDict[src]
impl ToBorrowedObject for PyDictfn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, [src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl Debug for PyDict[src]
impl Debug for PyDictfn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl Display for PyDict[src]
impl Display for PyDictfn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl<'a> FromPyObject<'a> for &'a PyDict[src]
impl<'a> FromPyObject<'a> for &'a PyDictfn extract(ob: &'a PyObjectRef) -> PyResult<Self>[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>Extracts Self from the source PyObject.
impl<'a> IntoIterator for &'a PyDict[src]
impl<'a> IntoIterator for &'a PyDicttype Item = (&'a PyObjectRef, &'a PyObjectRef)
The type of the elements being iterated over.
type IntoIter = PyDictIterator<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
fn into_iter(self) -> Self::IntoIterCreates an iterator from a value. Read more
impl<'a> IntoPyDictPointer for &'a PyDict[src]
impl<'a> IntoPyDictPointer for &'a PyDict