Struct cpython::PySequence[][src]

pub struct PySequence(_);

Represents a reference to a python object supporting the sequence protocol.

Implementations

impl PySequence[src]

pub fn len(&self, py: Python<'_>) -> PyResult<isize>[src]

Returns the number of objects in sequence. This is equivalent to Python len().

pub fn concat(&self, py: Python<'_>, other: &PySequence) -> PyResult<PyObject>[src]

Return the concatenation of o1 and o2. Equivalent to python o1 + o2

pub fn repeat(&self, py: Python<'_>, count: isize) -> PyResult<PyObject>[src]

Return the result of repeating sequence object o count times. Equivalent to python o * count NB: Python accepts negative counts; it returns an empty Sequence.

pub fn in_place_concat(
    &self,
    py: Python<'_>,
    other: &PySequence
) -> PyResult<PyObject>
[src]

Return the concatenation of o1 and o2 on success. Equivalent to python o1 += o2

pub fn in_place_repeat(
    &self,
    py: Python<'_>,
    count: isize
) -> PyResult<PyObject>
[src]

Return the result of repeating sequence object o count times. Equivalent to python o *= count NB: Python accepts negative counts; it empties the Sequence.

pub fn get_item(&self, py: Python<'_>, index: isize) -> PyResult<PyObject>[src]

Return the ith element of the Sequence. Equivalent to python o[index]

pub fn get_slice(
    &self,
    py: Python<'_>,
    begin: isize,
    end: isize
) -> PyResult<PyObject>
[src]

Return the slice of sequence object o between begin and end. This is the equivalent of the Python expression o[begin:end]

pub fn set_item(&self, py: Python<'_>, i: isize, v: &PyObject) -> PyResult<()>[src]

Assign object v to the ith element of o. Equivalent to Python statement o[i] = v

pub fn del_item(&self, py: Python<'_>, i: isize) -> PyResult<()>[src]

Delete the ith element of object o. Python statement del o[i]

pub fn set_slice(
    &self,
    py: Python<'_>,
    i1: isize,
    i2: isize,
    v: &PyObject
) -> PyResult<()>
[src]

Assign the sequence object v to the slice in sequence object o from i1 to i2. This is the equivalent of the Python statement o[i1:i2] = v

pub fn del_slice(&self, py: Python<'_>, i1: isize, i2: isize) -> PyResult<()>[src]

Delete the slice in sequence object o from i1 to i2. equivalent of the Python statement del o[i1:i2]

pub fn count<V>(&self, py: Python<'_>, value: V) -> PyResult<usize> where
    V: ToPyObject
[src]

Return the number of occurrences of value in o, that is, return the number of keys for which o[key] == value

pub fn contains<V>(&self, py: Python<'_>, value: V) -> PyResult<bool> where
    V: ToPyObject
[src]

Determine if o contains value. this is equivalent to the Python expression value in o

pub fn index<V>(&self, py: Python<'_>, value: V) -> PyResult<usize> where
    V: ToPyObject
[src]

Return the first index i for which o[i] == value. This is equivalent to the Python expression o.index(value)

pub fn list(&self, py: Python<'_>) -> PyResult<PyList>[src]

Return a fresh list based on the Sequence.

pub fn tuple(&self, py: Python<'_>) -> PyResult<PyTuple>[src]

Return a fresh tuple based on the Sequence.

pub fn iter<'p>(&self, py: Python<'p>) -> PyResult<PyIterator<'p>>[src]

Trait Implementations

impl<'s> FromPyObject<'s> for PySequence[src]

impl<'s> FromPyObject<'s> for &'s PySequence[src]

impl PythonObject for PySequence[src]

unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]

Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.

unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]

Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.

impl PythonObjectWithCheckedDowncast for PySequence[src]

impl ToPyObject for PySequence[src]

Identity conversion: allows using existing PyObject instances where T: ToPyObject is expected.

type ObjectType = PySequence

Auto Trait Implementations

impl RefUnwindSafe for PySequence[src]

impl Send for PySequence[src]

impl Sync for PySequence[src]

impl Unpin for PySequence[src]

impl UnwindSafe for PySequence[src]

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, 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.