Struct pyo3::PyDict
[−]
[src]
pub struct PyDict(_);
Represents a Python dict
.
Methods
impl PyDict
[src]
fn new(py: Python) -> &PyDict
[src]
Creates a new empty dictionary.
May panic when running out of memory.
fn copy(&self) -> PyResult<&PyDict>
[src]
Return a new dictionary that contains the same key-value pairs as self.
Corresponds to dict(self)
in Python.
fn clear(&self)
[src]
Empty an existing dictionary of all key-value pairs.
fn len(&self) -> usize
[src]
Return the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
fn contains<K>(&self, key: K) -> PyResult<bool> where
K: ToBorrowedObject,
[src]
K: ToBorrowedObject,
Determine if the dictionary contains the specified key.
This is equivalent to the Python expression key in self
.
fn get_item<K>(&self, key: K) -> Option<&PyObjectRef> where
K: ToBorrowedObject,
[src]
K: ToBorrowedObject,
Gets an item from the dictionary. Returns None if the item is not present, or if an error occurs.
fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()> where
K: ToPyObject,
V: ToPyObject,
[src]
K: ToPyObject,
V: ToPyObject,
Sets an item value.
This is equivalent to the Python expression self[key] = value
.
fn del_item<K>(&self, key: K) -> PyResult<()> where
K: ToBorrowedObject,
[src]
K: ToBorrowedObject,
Deletes an item.
This is equivalent to the Python expression del self[key]
.
fn keys(&self) -> &PyList
[src]
List of dict keys.
This is equivalent to the python expression list(dict.keys())
.
fn values(&self) -> &PyList
[src]
List of dict values.
This is equivalent to the python expression list(dict.values())
.
fn items(&self) -> &PyList
[src]
List of dict items.
This is equivalent to the python expression list(dict.items())
.
fn iter(&self) -> PyDictIterator
[src]
Returns 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 AsRef<PyObjectRef> for PyDict
[src]
fn as_ref(&self) -> &PyObjectRef
[src]
Performs the conversion.
impl PyObjectWithToken for PyDict
[src]
impl ToPyPointer for PyDict
[src]
impl PartialEq for PyDict
[src]
fn eq(&self, o: &PyDict) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PyTypeInfo for PyDict
[src]
type 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]
PyTypeObject instance for this type
fn is_instance(ptr: *mut PyObject) -> bool
[src]
Check 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]
Check if *mut ffi::PyObject
is exact instance of this type
impl PyTypeObject for PyDict
[src]
fn init_type()
[src]
Initialize type object
fn type_object() -> Py<PyType>
[src]
Retrieves the type object for this Python object type.
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
[src]
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
Create PyRawObject which can be initialized with rust value
impl ToPyObject for PyDict
[src]
impl ToBorrowedObject for PyDict
[src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
[src]
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]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl Display for PyDict
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<'a> FromPyObject<'a> for &'a PyDict
[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
[src]
Extracts Self
from the source PyObject
.
impl<'a> IntoIterator for &'a PyDict
[src]
type 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]
Creates an iterator from a value. Read more