Struct cpython::PyList [−][src]
pub struct PyList(_);
Represents a Python list.
Methods
impl PyList[src]
impl PyListpub fn new(py: Python, elements: &[PyObject]) -> PyList[src]
pub fn new(py: Python, elements: &[PyObject]) -> PyListConstruct a new list with the given elements.
pub fn len(&self, _py: Python) -> usize[src]
pub fn len(&self, _py: Python) -> usizeGets the length of the list.
pub fn get_item(&self, py: Python, index: usize) -> PyObject[src]
pub fn get_item(&self, py: Python, index: usize) -> PyObjectGets the item at the specified index.
Panics if the index is out of range.
pub fn set_item(&self, _py: Python, index: usize, item: PyObject)[src]
pub fn set_item(&self, _py: Python, index: usize, item: PyObject)Sets the item at the specified index.
Panics if the index is out of range.
pub fn insert_item(&self, _py: Python, index: usize, item: PyObject)[src]
pub fn insert_item(&self, _py: Python, index: usize, item: PyObject)Inserts an item at the specified index.
Panics if the index is out of range.
pub fn iter<'a, 'p>(&'a self, py: Python<'p>) -> PyListIterator<'a, 'p>[src]
pub fn iter<'a, 'p>(&'a self, py: Python<'p>) -> PyListIterator<'a, 'p>Trait Implementations
impl ToPyObject for PyList[src]
impl ToPyObject for PyListIdentity conversion: allows using existing PyObject instances where
T: ToPyObject is expected.
type ObjectType = PyList
fn to_py_object(&self, py: Python) -> PyList[src]
fn to_py_object(&self, py: Python) -> PyListConverts self into a Python object.
fn into_py_object(self, _py: Python) -> PyList[src]
fn into_py_object(self, _py: Python) -> PyListConverts self into a Python object. Read more
fn 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<'source> FromPyObject<'source> for PyList[src]
impl<'source> FromPyObject<'source> for PyListfn extract(py: Python, obj: &'source PyObject) -> PyResult<PyList>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PyList>Extracts Self from the source PyObject.
impl<'source> FromPyObject<'source> for &'source PyList[src]
impl<'source> FromPyObject<'source> for &'source PyListfn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyList>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyList>Extracts Self from the source PyObject.
impl PythonObject for PyList[src]
impl PythonObject for PyListfn as_object(&self) -> &PyObject[src]
fn as_object(&self) -> &PyObjectCasts the Python object to PyObject.
fn into_object(self) -> PyObject[src]
fn into_object(self) -> PyObjectCasts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]
unsafe fn unchecked_downcast_from(obj: PyObject) -> SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
ⓘImportant traits for &'a mut Runsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PyList[src]
impl PythonObjectWithCheckedDowncast for PyListfn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyList, PythonObjectDowncastError<'p>>[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyList, PythonObjectDowncastError<'p>>Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyList, PythonObjectDowncastError<'p>>[src]
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyList, PythonObjectDowncastError<'p>>Cast from PyObject to a concrete Python object type.
impl PythonObjectWithTypeObject for PyList[src]
impl PythonObjectWithTypeObject for PyListfn type_object(py: Python) -> PyType[src]
fn type_object(py: Python) -> PyTypeRetrieves the type object for this Python object type.