[][src]Struct pyo3::types::PySequence

#[repr(transparent)]pub struct PySequence(_, _);

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

Methods

impl PySequence[src]

pub fn len(&self) -> PyResult<isize>[src]

Returns the number of objects in sequence.

This is equivalent to the Python expression len(self).

pub fn is_empty(&self) -> PyResult<bool>[src]

pub fn concat(&self, other: &PySequence) -> PyResult<&PySequence>[src]

Returns the concatenation of self and other.

This is equivalent to the Python expression self + other.

pub fn repeat(&self, count: isize) -> PyResult<&PySequence>[src]

Returns the result of repeating a sequence object count times.

This is equivalent to the Python expression self * count. NB: Python accepts negative counts; it returns an empty Sequence.

pub fn in_place_concat(&self, other: &PySequence) -> PyResult<()>[src]

Concatenates self and other in place.

This is equivalent to the Python statement self += other.

pub fn in_place_repeat(&self, count: isize) -> PyResult<()>[src]

Repeats the sequence object count times and updates self.

This is equivalent to the Python statement self *= count. NB: Python accepts negative counts; it empties the Sequence.

pub fn get_item(&self, index: isize) -> PyResult<&PyAny>[src]

Returns the indexth element of the Sequence.

This is equivalent to the Python expression self[index].

pub fn get_slice(&self, begin: isize, end: isize) -> PyResult<&PyAny>[src]

Returns the slice of sequence object between begin and end.

This is equivalent to the Python expression self[begin:end].

pub fn set_item<I>(&self, i: isize, item: I) -> PyResult<()> where
    I: ToBorrowedObject
[src]

Assigns object item to the ith element of self.

This is equivalent to the Python statement self[i] = v.

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

Deletes the ith element of self.

This is equivalent to the Python statement del self[i].

pub fn set_slice(&self, i1: isize, i2: isize, v: &PyAny) -> PyResult<()>[src]

Assigns the sequence v to the slice of self from i1 to i2.

This is equivalent to the Python statement self[i1:i2] = v.

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

Deletes the slice from i1 to i2 from self.

This is equivalent to the Python statement del self[i1:i2].

pub fn count<V>(&self, value: V) -> PyResult<usize> where
    V: ToBorrowedObject
[src]

Returns the number of occurrences of value in self, that is, return the number of keys for which self[key] == value.

pub fn contains<V>(&self, value: V) -> PyResult<bool> where
    V: ToBorrowedObject
[src]

Determines if self contains value.

This is equivalent to the Python expression value in self.

pub fn index<V>(&self, value: V) -> PyResult<usize> where
    V: ToBorrowedObject
[src]

Returns the first index i for which self[i] == value.

This is equivalent to the Python expression self.index(value).

pub fn list(&self) -> PyResult<&PyList>[src]

Returns a fresh list based on the Sequence.

pub fn tuple(&self) -> PyResult<&PyTuple>[src]

Returns a fresh tuple based on the Sequence.

Trait Implementations

impl AsPyPointer for PySequence[src]

fn as_ptr(&self) -> *mut PyObject[src]

Gets the underlying FFI pointer, returns a borrowed pointer.

impl AsRef<PyAny> for PySequence[src]

impl PartialEq<PySequence> for PySequence[src]

impl PyNativeType for PySequence[src]

impl<'v> PyTryFrom<'v> for PySequence[src]

Auto Trait Implementations

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> FromPy<T> for T[src]

impl<'p, T> FromPyPointer<'p> for T where
    T: 'p + PyNativeType
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoPy<U> for T where
    U: FromPy<T>, 
[src]

impl<'py, T> PyDowncastImpl for T where
    T: 'py + PyNativeType
[src]

impl<'v, T> PyTryFrom<'v> for T where
    T: PyDowncastImpl + PyTypeInfo + PyNativeType
[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.