Struct cpython::PySet[][src]

pub struct PySet(_);

Represents a Python set.

Implementations

impl PySet[src]

pub fn new<I>(py: Python<'_>, iterable: I) -> PyResult<PySet> where
    I: ToPyObject
[src]

Creates a new set from any iterable

Corresponds to set(iterable) in Python.

pub fn empty(py: Python<'_>) -> PyResult<PySet>[src]

Creates an empty set

Corresponds to set() in Python

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

Empty an existing set of all values.

pub fn len(&self, _py: Python<'_>) -> usize[src]

Return the number of items in the set This is equivalent to Python len(self)

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

Determine if the set contains the specified value. This is equivalent to the Python expression value in self.

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

Add a value. This is equivalent to the Python expression self.add(value).

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

Discard a value This is equivalent to the Python expression self.discard(value).

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

Pop a value This is equivalent to the Python expression self.pop(value). We get KeyError if the set is empty

Trait Implementations

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

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

impl PythonObject for PySet[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 PySet[src]

impl PythonObjectWithTypeObject for PySet[src]

impl ToPyObject for PySet[src]

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

type ObjectType = PySet

Auto Trait Implementations

impl RefUnwindSafe for PySet[src]

impl Send for PySet[src]

impl Sync for PySet[src]

impl Unpin for PySet[src]

impl UnwindSafe for PySet[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.