Struct pyo3::prelude::PySet
[−]
[src]
pub struct PySet(_);
Represents a Python set
Methods
impl PySet
[src]
pub fn new<T: ToPyObject>(py: Python, elements: &[T]) -> Py<PySet>
[src]
Creates a new set.
May panic when running out of memory.
pub fn clear(&self)
[src]
Remove all elements from the set.
pub fn len(&self) -> usize
[src]
Return the number of items in the set. This is equivalent to len(p) on a set.
pub fn is_empty(&self) -> bool
[src]
Check if set is empty.
pub fn contains<K>(&self, key: K) -> PyResult<bool> where
K: ToPyObject,
[src]
K: ToPyObject,
Determine if the set contains the specified key.
This is equivalent to the Python expression key in self
.
pub fn discard<K>(&self, key: K) where
K: ToPyObject,
[src]
K: ToPyObject,
Remove element from the set if it is present.
pub fn add<K>(&self, key: K) -> PyResult<()> where
K: ToPyObject,
[src]
K: ToPyObject,
Add element to the set.
pub fn pop(&self) -> Option<PyObject>
[src]
Remove and return an arbitrary element from the set
Trait Implementations
impl<'a> From<&'a PySet> for &'a PyObjectRef
[src]
impl AsRef<PyObjectRef> for PySet
[src]
fn as_ref(&self) -> &PyObjectRef
[src]
Performs the conversion.
impl PyObjectWithToken for PySet
[src]
impl ToPyPointer for PySet
[src]
impl PartialEq for PySet
[src]
fn eq(&self, o: &PySet) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PyTypeInfo for PySet
[src]
type Type = ()
Type of objects to store in PyObject struct
type BaseType = PyObjectRef
Base class
const NAME: &'static str
NAME: &'static str = "PySet"
Class name
const SIZE: usize
SIZE: usize = ::std::mem::size_of::<::ffi::PyObject>()
Size of the rust PyObject structure (PyObject + rust structure)
const OFFSET: isize
OFFSET: isize = 0
Type
instance offset inside PyObject structure
unsafe fn type_object() -> &'static mut PyTypeObject
[src]
PyTypeObject instance for this type
fn is_instance(ptr: *mut PyObject) -> bool
[src]
Check if *mut ffi::PyObject
is instance of this type
const DESCRIPTION: &'static str
DESCRIPTION: &'static str = "\u{0}"
Class doc string
const FLAGS: usize
FLAGS: usize = 0
Type flags (ie PY_TYPE_FLAG_GC, PY_TYPE_FLAG_WEAKREF)
fn is_exact_instance(ptr: *mut PyObject) -> bool
[src]
Check if *mut ffi::PyObject
is exact instance of this type
impl PyTypeObject for PySet
[src]
fn init_type()
[src]
Initialize type object
fn type_object() -> Py<PyType>
[src]
Retrieves the type object for this Python object type.
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
[src]
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
Create PyRawObject which can be initialized with rust value
impl ToPyObject for PySet
[src]
impl ToBorrowedObject for 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,
Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl Debug for PySet
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl Display for PySet
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<'a> FromPyObject<'a> for &'a PySet
[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
[src]
Extracts Self
from the source PyObject
.