[−][src]Struct cpython::PySet
Represents a Python set.
Methods
impl PySet[src]
pub fn new<I>(py: Python, iterable: I) -> PyResult<PySet> where
I: ToPyObject, [src]
I: ToPyObject,
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]
V: ToPyObject,
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]
V: ToPyObject,
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]
V: ToPyObject,
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]
fn as_object(&self) -> &PyObject[src]
fn into_object(self) -> PyObject[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]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PySet, PythonObjectDowncastError<'p>>[src]
py: Python<'p>,
obj: PyObject
) -> Result<PySet, PythonObjectDowncastError<'p>>
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PySet, PythonObjectDowncastError<'p>>[src]
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PySet, PythonObjectDowncastError<'p>>
impl PythonObjectWithTypeObject for PySet[src]
fn type_object(py: Python) -> PyType[src]
impl ToPyObject for PySet[src]
Identity conversion: allows using existing PyObject instances where
T: ToPyObject is expected.
type ObjectType = PySet
fn to_py_object(&self, py: Python) -> PySet[src]
fn into_py_object(self, _py: Python) -> PySet[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,
Auto Trait Implementations
impl RefUnwindSafe for PySet
impl Send for PySet
impl Sync for PySet
impl Unpin for PySet
impl UnwindSafe for PySet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,