pyo3::prelude

Struct Bound

Source
pub struct Bound<'py, T>(/* private fields */);
Expand description

A GIL-attached equivalent to Py<T>.

This type can be thought of as equivalent to the tuple (Py<T>, Python<'py>). By having the 'py lifetime of the [Python<'py>] token, this ties the lifetime of the [Bound<'py, T>] smart pointer to the lifetime of the GIL and allows PyO3 to call Python APIs at maximum efficiency.

To access the object in situations where the GIL is not held, convert it to Py<T> using .unbind(). This includes situations where the GIL is temporarily released, such as Python::allow_threads’s closure.

See the guide for more detail.

Implementations§

Source§

impl<'py, T> Bound<'py, T>
where T: PyClass,

Source

pub fn new( py: Python<'py>, value: impl Into<PyClassInitializer<T>>, ) -> PyResult<Bound<'py, T>>

Creates a new instance Bound<T> of a #[pyclass] on the Python heap.

§Examples
use pyo3::prelude::*;

#[pyclass]
struct Foo {/* fields omitted */}

let foo: Py<Foo> = Python::with_gil(|py| -> PyResult<_> {
    let foo: Bound<'_, Foo> = Bound::new(py, Foo {})?;
    Ok(foo.into())
})?;
Source§

impl<'py> Bound<'py, PyAny>

Source

pub unsafe fn from_owned_ptr(py: Python<'py>, ptr: *mut PyObject) -> Self

Constructs a new Bound<'py, PyAny> from a pointer. Panics if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object
  • ptr must be an owned Python reference, as the Bound<'py, PyAny> will assume ownership
Source

pub unsafe fn from_owned_ptr_or_opt( py: Python<'py>, ptr: *mut PyObject, ) -> Option<Self>

Constructs a new Bound<'py, PyAny> from a pointer. Returns None if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object, or null
  • ptr must be an owned Python reference, as the Bound<'py, PyAny> will assume ownership
Source

pub unsafe fn from_owned_ptr_or_err( py: Python<'py>, ptr: *mut PyObject, ) -> PyResult<Self>

Constructs a new Bound<'py, PyAny> from a pointer. Returns an Err by calling PyErr::fetch if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object, or null
  • ptr must be an owned Python reference, as the Bound<'py, PyAny> will assume ownership
Source

pub unsafe fn from_borrowed_ptr(py: Python<'py>, ptr: *mut PyObject) -> Self

Constructs a new Bound<'py, PyAny> from a pointer by creating a new Python reference. Panics if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object
Source

pub unsafe fn from_borrowed_ptr_or_opt( py: Python<'py>, ptr: *mut PyObject, ) -> Option<Self>

Constructs a new Bound<'py, PyAny> from a pointer by creating a new Python reference. Returns None if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object, or null
Source

pub unsafe fn from_borrowed_ptr_or_err( py: Python<'py>, ptr: *mut PyObject, ) -> PyResult<Self>

Constructs a new Bound<'py, PyAny> from a pointer by creating a new Python reference. Returns an Err by calling PyErr::fetch if ptr is null.

§Safety
  • ptr must be a valid pointer to a Python object, or null
Source§

impl<'py, T> Bound<'py, T>
where T: PyClass,

Source

pub fn borrow(&self) -> PyRef<'py, T>

Immutably borrows the value T.

This borrow lasts while the returned PyRef exists. Multiple immutable borrows can be taken out at the same time.

For frozen classes, the simpler get is available.

§Examples
#[pyclass]
struct Foo {
    inner: u8,
}

Python::with_gil(|py| -> PyResult<()> {
    let foo: Bound<'_, Foo> = Bound::new(py, Foo { inner: 73 })?;
    let inner: &u8 = &foo.borrow().inner;

    assert_eq!(*inner, 73);
    Ok(())
})?;
§Panics

Panics if the value is currently mutably borrowed. For a non-panicking variant, use try_borrow.

Source

pub fn borrow_mut(&self) -> PyRefMut<'py, T>
where T: PyClass<Frozen = False>,

Mutably borrows the value T.

This borrow lasts while the returned PyRefMut exists.

§Examples
#[pyclass]
struct Foo {
    inner: u8,
}

Python::with_gil(|py| -> PyResult<()> {
    let foo: Bound<'_, Foo> = Bound::new(py, Foo { inner: 73 })?;
    foo.borrow_mut().inner = 35;

    assert_eq!(foo.borrow().inner, 35);
    Ok(())
})?;
§Panics

Panics if the value is currently borrowed. For a non-panicking variant, use try_borrow_mut.

Source

pub fn try_borrow(&self) -> Result<PyRef<'py, T>, PyBorrowError>

Attempts to immutably borrow the value T, returning an error if the value is currently mutably borrowed.

The borrow lasts while the returned PyRef exists.

This is the non-panicking variant of borrow.

For frozen classes, the simpler get is available.

Source

pub fn try_borrow_mut(&self) -> Result<PyRefMut<'py, T>, PyBorrowMutError>
where T: PyClass<Frozen = False>,

Attempts to mutably borrow the value T, returning an error if the value is currently borrowed.

The borrow lasts while the returned PyRefMut exists.

This is the non-panicking variant of borrow_mut.

Source

pub fn get(&self) -> &T
where T: PyClass<Frozen = True> + Sync,

Provide an immutable borrow of the value T without acquiring the GIL.

This is available if the class is frozen and Sync.

§Examples
use std::sync::atomic::{AtomicUsize, Ordering};

#[pyclass(frozen)]
struct FrozenCounter {
    value: AtomicUsize,
}

Python::with_gil(|py| {
    let counter = FrozenCounter { value: AtomicUsize::new(0) };

    let py_counter = Bound::new(py, counter).unwrap();

    py_counter.get().value.fetch_add(1, Ordering::Relaxed);
});
Source

pub fn as_super(&self) -> &Bound<'py, T::BaseType>

Upcast this Bound<PyClass> to its base type by reference.

If this type defined an explicit base class in its pyclass declaration (e.g. #[pyclass(extends = BaseType)]), the returned type will be &Bound<BaseType>. If an explicit base class was not declared, the return value will be &Bound<PyAny> (making this method equivalent to as_any).

This method is particularly useful for calling methods defined in an extension trait that has been implemented for Bound<BaseType>.

See also the into_super method to upcast by value, and the PyRef::as_super/PyRefMut::as_super methods for upcasting a pyclass that has already been borrowed.

§Example: Calling a method defined on the Bound base type
use pyo3::prelude::*;

#[pyclass(subclass)]
struct BaseClass;

trait MyClassMethods<'py> {
    fn pyrepr(&self) -> PyResult<String>;
}
impl<'py> MyClassMethods<'py> for Bound<'py, BaseClass> {
    fn pyrepr(&self) -> PyResult<String> {
        self.call_method0("__repr__")?.extract()
    }
}

#[pyclass(extends = BaseClass)]
struct SubClass;

Python::with_gil(|py| {
    let obj = Bound::new(py, (SubClass, BaseClass)).unwrap();
    assert!(obj.as_super().pyrepr().is_ok());
})
Source

pub fn into_super(self) -> Bound<'py, T::BaseType>

Upcast this Bound<PyClass> to its base type by value.

If this type defined an explicit base class in its pyclass declaration (e.g. #[pyclass(extends = BaseType)]), the returned type will be Bound<BaseType>. If an explicit base class was not declared, the return value will be Bound<PyAny> (making this method equivalent to into_any).

This method is particularly useful for calling methods defined in an extension trait that has been implemented for Bound<BaseType>.

See also the as_super method to upcast by reference, and the PyRef::into_super/PyRefMut::into_super methods for upcasting a pyclass that has already been borrowed.

§Example: Calling a method defined on the Bound base type
use pyo3::prelude::*;

#[pyclass(subclass)]
struct BaseClass;

trait MyClassMethods<'py> {
    fn pyrepr(self) -> PyResult<String>;
}
impl<'py> MyClassMethods<'py> for Bound<'py, BaseClass> {
    fn pyrepr(self) -> PyResult<String> {
        self.call_method0("__repr__")?.extract()
    }
}

#[pyclass(extends = BaseClass)]
struct SubClass;

Python::with_gil(|py| {
    let obj = Bound::new(py, (SubClass, BaseClass)).unwrap();
    assert!(obj.into_super().pyrepr().is_ok());
})
Source§

impl<'py, T> Bound<'py, T>

Source

pub fn py(&self) -> Python<'py>

Returns the GIL token associated with this object.

Source

pub fn as_ptr(&self) -> *mut PyObject

Returns the raw FFI pointer represented by self.

§Safety

Callers are responsible for ensuring that the pointer does not outlive self.

The reference is borrowed; callers should not decrease the reference count when they are finished with the pointer.

Source

pub fn into_ptr(self) -> *mut PyObject

Returns an owned raw FFI pointer represented by self.

§Safety

The reference is owned; when finished the caller should either transfer ownership of the pointer or decrease the reference count (e.g. with pyo3::ffi::Py_DecRef).

Source

pub fn as_any(&self) -> &Bound<'py, PyAny>

Helper to cast to Bound<'py, PyAny>.

Source

pub fn into_any(self) -> Bound<'py, PyAny>

Helper to cast to Bound<'py, PyAny>, transferring ownership.

Source

pub fn as_borrowed<'a>(&'a self) -> Borrowed<'a, 'py, T>

Casts this Bound<T> to a Borrowed<T> smart pointer.

Source

pub fn unbind(self) -> Py<T>

Removes the connection for this Bound<T> from the GIL, allowing it to cross thread boundaries.

Source

pub fn as_unbound(&self) -> &Py<T>

Removes the connection for this Bound<T> from the GIL, allowing it to cross thread boundaries, without transferring ownership.

Trait Implementations§

Source§

impl<'py> Add<&Bound<'py, PyComplex>> for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the + operator.
Source§

fn add(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the + operation. Read more
Source§

impl<'py> Add<Bound<'py, PyComplex>> for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the + operator.
Source§

fn add(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the + operation. Read more
Source§

impl<'py> Add for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the + operator.
Source§

fn add(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the + operation. Read more
Source§

impl<'py> Add for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the + operator.
Source§

fn add(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the + operation. Read more
Source§

impl<T> AsPyPointer for Bound<'_, T>

Source§

fn as_ptr(&self) -> *mut PyObject

Returns the underlying FFI pointer as a borrowed pointer.
Source§

impl<'py, T> AsRef<Bound<'py, PyAny>> for Bound<'py, T>

Source§

fn as_ref(&self) -> &Bound<'py, PyAny>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'py, T> BoundObject<'py, T> for Bound<'py, T>

Source§

type Any = Bound<'py, PyAny>

Type erased version of Self
Source§

fn as_borrowed(&self) -> Borrowed<'_, 'py, T>

Borrow this smart pointer.
Source§

fn into_bound(self) -> Bound<'py, T>

Turns this smart pointer into an owned [Bound<'py, T>]
Source§

fn into_any(self) -> Self::Any

Upcast the target type of this smart pointer
Source§

fn into_ptr(self) -> *mut PyObject

Turn this smart pointer into a strong reference pointer
Source§

fn as_ptr(&self) -> *mut PyObject

Turn this smart pointer into a borrowed reference pointer
Source§

fn unbind(self) -> Py<T>

Turn this smart pointer into an owned Py<T>
Source§

impl<T> Clone for Bound<'_, T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Bound<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'py, T> Deref for Bound<'py, T>
where T: DerefToPyAny,

Source§

type Target = Bound<'py, PyAny>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Bound<'py, PyAny>

Dereferences the value.
Source§

impl<T> Display for Bound<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'py> Div<&Bound<'py, PyComplex>> for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the / operator.
Source§

fn div(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the / operation. Read more
Source§

impl<'py> Div<Bound<'py, PyComplex>> for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the / operator.
Source§

fn div(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the / operation. Read more
Source§

impl<'py> Div for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the / operator.
Source§

fn div(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the / operation. Read more
Source§

impl<'py> Div for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the / operator.
Source§

fn div(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the / operation. Read more
Source§

impl<T> Drop for Bound<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, 'py, T> From<&'a Bound<'py, T>> for Borrowed<'a, 'py, T>

Source§

fn from(instance: &'a Bound<'py, T>) -> Self

Create borrow on a Bound

Source§

impl From<Bound<'_, PyByteArray>> for PyBackedBytes

Source§

fn from(py_bytearray: Bound<'_, PyByteArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Bound<'_, PyBytes>> for PyBackedBytes

Source§

fn from(py_bytes: Bound<'_, PyBytes>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Bound<'_, T>> for PyObject
where T: AsRef<PyAny>,

Source§

fn from(other: Bound<'_, T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Bound<'_, T>> for Py<T>

Source§

fn from(other: Bound<'_, T>) -> Self

Converts to this type from the input type.
Source§

impl<'py, T: PyClass> From<Bound<'py, T>> for PyClassInitializer<T>

Source§

fn from(value: Bound<'py, T>) -> PyClassInitializer<T>

Converts to this type from the input type.
Source§

impl<'py, T> From<Bound<'py, T>> for PyErr
where T: ToPyErr,

Source§

fn from(err: Bound<'py, T>) -> PyErr

Converts to this type from the input type.
Source§

impl<'py, T> FromPyObject<'py> for Bound<'py, T>
where T: PyTypeCheck,

Source§

fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self>

Extracts Self from the source PyObject.

Source§

fn type_input() -> TypeInfo

Extracts the type hint information for this type when it appears as an argument. Read more
Source§

impl<I: SliceIndex<[u8]>> Index<I> for Bound<'_, PyBytes>

This is the same way Vec is indexed.

Source§

type Output = <I as SliceIndex<[u8]>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'py> IntoIterator for &Bound<'py, PyDict>

Source§

type Item = (Bound<'py, PyAny>, Bound<'py, PyAny>)

The type of the elements being iterated over.
Source§

type IntoIter = BoundDictIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for &Bound<'py, PyFrozenSet>

Source§

fn into_iter(self) -> Self::IntoIter

Returns an iterator of values in this set.

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundFrozenSetIterator<'py>

Which kind of iterator are we turning this into?
Source§

impl<'py> IntoIterator for &Bound<'py, PyIterator>

Source§

type Item = Result<Bound<'py, PyAny>, PyErr>

The type of the elements being iterated over.
Source§

type IntoIter = Bound<'py, PyIterator>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for &Bound<'py, PyList>

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundListIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for &Bound<'py, PySet>

Source§

fn into_iter(self) -> Self::IntoIter

Returns an iterator of values in this set.

§Panics

If PyO3 detects that the set is mutated during iteration, it will panic.

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundSetIterator<'py>

Which kind of iterator are we turning this into?
Source§

impl<'py> IntoIterator for &Bound<'py, PyTuple>

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundTupleIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for Bound<'py, PyDict>

Source§

type Item = (Bound<'py, PyAny>, Bound<'py, PyAny>)

The type of the elements being iterated over.
Source§

type IntoIter = BoundDictIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for Bound<'py, PyFrozenSet>

Source§

fn into_iter(self) -> Self::IntoIter

Returns an iterator of values in this set.

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundFrozenSetIterator<'py>

Which kind of iterator are we turning this into?
Source§

impl<'py> IntoIterator for Bound<'py, PyList>

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundListIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'py> IntoIterator for Bound<'py, PySet>

Source§

fn into_iter(self) -> Self::IntoIter

Returns an iterator of values in this set.

§Panics

If PyO3 detects that the set is mutated during iteration, it will panic.

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundSetIterator<'py>

Which kind of iterator are we turning this into?
Source§

impl<'py> IntoIterator for Bound<'py, PyTuple>

Source§

type Item = Bound<'py, PyAny>

The type of the elements being iterated over.
Source§

type IntoIter = BoundTupleIterator<'py>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoPy<Py<PyAny>> for &Bound<'_, T>

Source§

fn into_py(self, py: Python<'_>) -> PyObject

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.

Converts &Bound instance -> PyObject, increasing the reference count.

Source§

impl<T> IntoPy<Py<PyAny>> for Bound<'_, T>

Source§

fn into_py(self, _py: Python<'_>) -> PyObject

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.

Converts a Bound instance to PyObject.

Source§

impl IntoPy<Py<PyString>> for &Bound<'_, PyString>

Source§

fn into_py(self, _py: Python<'_>) -> Py<PyString>

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.
Performs the conversion.
Source§

impl IntoPy<Py<PyString>> for Bound<'_, PyString>

Source§

fn into_py(self, _py: Python<'_>) -> Py<PyString>

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.
Performs the conversion.
Source§

impl IntoPy<Py<PyTuple>> for &Bound<'_, PyTuple>

Source§

fn into_py(self, _: Python<'_>) -> Py<PyTuple>

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.
Performs the conversion.
Source§

impl IntoPy<Py<PyTuple>> for Bound<'_, PyTuple>

Source§

fn into_py(self, _: Python<'_>) -> Py<PyTuple>

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.
Performs the conversion.
Source§

impl<'a, 'py, T> IntoPyObject<'py> for &'a Bound<'py, T>

Source§

type Target = T

The Python output type
Source§

type Output = Borrowed<'a, 'py, <&'a Bound<'py, T> as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>

Performs the conversion.
Source§

fn type_output() -> TypeInfo

Extracts the type hint information for this type when it appears as a return value. Read more
Source§

impl<'py, T> IntoPyObject<'py> for Bound<'py, T>

Source§

type Target = T

The Python output type
Source§

type Output = Bound<'py, <Bound<'py, T> as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>

Performs the conversion.
Source§

fn type_output() -> TypeInfo

Extracts the type hint information for this type when it appears as a return value. Read more
Source§

impl<'py> Iterator for Bound<'py, PyIterator>

Source§

fn next(&mut self) -> Option<Self::Item>

Retrieves the next item from an iterator.

Returns None when the iterator is exhausted. If an exception occurs, returns Some(Err(..)). Further next() calls after an exception occurs are likely to repeatedly result in the same exception.

Source§

type Item = Result<Bound<'py, PyAny>, PyErr>

The type of the elements being iterated over.
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator. Read more
Source§

fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

🔬This is a nightly-only experimental API. (iter_next_chunk)
Advances the iterator and returns an array containing the next N values. Read more
1.0.0 · Source§

fn count(self) -> usize
where Self: Sized,

Consumes the iterator, counting the number of iterations and returning it. Read more
1.0.0 · Source§

fn last(self) -> Option<Self::Item>
where Self: Sized,

Consumes the iterator, returning the last element. Read more
Source§

fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

🔬This is a nightly-only experimental API. (iter_advance_by)
Advances the iterator by n elements. Read more
1.0.0 · Source§

fn nth(&mut self, n: usize) -> Option<Self::Item>

Returns the nth element of the iterator. Read more
1.28.0 · Source§

fn step_by(self, step: usize) -> StepBy<Self>
where Self: Sized,

Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more
1.0.0 · Source§

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
where Self: Sized, U: IntoIterator<Item = Self::Item>,

Takes two iterators and creates a new iterator over both in sequence. Read more
1.0.0 · Source§

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>
where Self: Sized, U: IntoIterator,

‘Zips up’ two iterators into a single iterator of pairs. Read more
Source§

fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where Self: Sized, Self::Item: Clone,

🔬This is a nightly-only experimental API. (iter_intersperse)
Creates a new iterator which places a copy of separator between adjacent items of the original iterator. Read more
Source§

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
where Self: Sized, G: FnMut() -> Self::Item,

🔬This is a nightly-only experimental API. (iter_intersperse)
Creates a new iterator which places an item generated by separator between adjacent items of the original iterator. Read more
1.0.0 · Source§

fn map<B, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> B,

Takes a closure and creates an iterator which calls that closure on each element. Read more
1.21.0 · Source§

fn for_each<F>(self, f: F)
where Self: Sized, F: FnMut(Self::Item),

Calls a closure on each element of an iterator. Read more
1.0.0 · Source§

fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator which uses a closure to determine if an element should be yielded. Read more
1.0.0 · Source§

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both filters and maps. Read more
1.0.0 · Source§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Creates an iterator which gives the current iteration count as well as the next value. Read more
1.0.0 · Source§

fn peekable(self) -> Peekable<Self>
where Self: Sized,

Creates an iterator which can use the peek and peek_mut methods to look at the next element of the iterator without consuming it. See their documentation for more information. Read more
1.0.0 · Source§

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator that skips elements based on a predicate. Read more
1.0.0 · Source§

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Creates an iterator that yields elements based on a predicate. Read more
1.57.0 · Source§

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
where Self: Sized, P: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both yields elements based on a predicate and maps. Read more
1.0.0 · Source§

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

Creates an iterator that skips the first n elements. Read more
1.0.0 · Source§

fn take(self, n: usize) -> Take<Self>
where Self: Sized,

Creates an iterator that yields the first n elements, or fewer if the underlying iterator ends sooner. Read more
1.0.0 · Source§

fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,

An iterator adapter which, like fold, holds internal state, but unlike fold, produces a new iterator. Read more
1.0.0 · Source§

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where Self: Sized, U: IntoIterator, F: FnMut(Self::Item) -> U,

Creates an iterator that works like map, but flattens nested structure. Read more
1.29.0 · Source§

fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Item: IntoIterator,

Creates an iterator that flattens nested structure. Read more
Source§

fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
where Self: Sized, F: FnMut(&[Self::Item; N]) -> R,

🔬This is a nightly-only experimental API. (iter_map_windows)
Calls the given function f for each contiguous window of size N over self and returns an iterator over the outputs of f. Like slice::windows(), the windows during mapping overlap as well. Read more
1.0.0 · Source§

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Creates an iterator which ends after the first None. Read more
1.0.0 · Source§

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where Self: Sized, F: FnMut(&Self::Item),

Does something with each element of an iterator, passing the value on. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Borrows an iterator, rather than consuming it. Read more
1.0.0 · Source§

fn collect<B>(self) -> B
where B: FromIterator<Self::Item>, Self: Sized,

Transforms an iterator into a collection. Read more
Source§

fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
where Self: Sized, Self::Item: Try, <Self::Item as Try>::Residual: Residual<B>, B: FromIterator<<Self::Item as Try>::Output>,

🔬This is a nightly-only experimental API. (iterator_try_collect)
Fallibly transforms an iterator into a collection, short circuiting if a failure is encountered. Read more
Source§

fn collect_into<E>(self, collection: &mut E) -> &mut E
where E: Extend<Self::Item>, Self: Sized,

🔬This is a nightly-only experimental API. (iter_collect_into)
Collects all the items from an iterator into a collection. Read more
1.0.0 · Source§

fn partition<B, F>(self, f: F) -> (B, B)
where Self: Sized, B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool,

Consumes an iterator, creating two collections from it. Read more
Source§

fn is_partitioned<P>(self, predicate: P) -> bool
where Self: Sized, P: FnMut(Self::Item) -> bool,

🔬This is a nightly-only experimental API. (iter_is_partitioned)
Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return true precede all those that return false. Read more
1.27.0 · Source§

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
where Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more
1.27.0 · Source§

fn try_for_each<F, R>(&mut self, f: F) -> R
where Self: Sized, F: FnMut(Self::Item) -> R, R: Try<Output = ()>,

An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error. Read more
1.0.0 · Source§

fn fold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item) -> B,

Folds every element into an accumulator by applying an operation, returning the final result. Read more
1.51.0 · Source§

fn reduce<F>(self, f: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,

Reduces the elements to a single one, by repeatedly applying a reducing operation. Read more
Source§

fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
where Self: Sized, R: Try<Output = Self::Item>, <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬This is a nightly-only experimental API. (iterator_try_reduce)
Reduces the elements to a single one by repeatedly applying a reducing operation. If the closure returns a failure, the failure is propagated back to the caller immediately. Read more
1.0.0 · Source§

fn all<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool,

Tests if every element of the iterator matches a predicate. Read more
1.0.0 · Source§

fn any<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool,

Tests if any element of the iterator matches a predicate. Read more
1.0.0 · Source§

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator that satisfies a predicate. Read more
1.30.0 · Source§

fn find_map<B, F>(&mut self, f: F) -> Option<B>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

Applies function to the elements of iterator and returns the first non-none result. Read more
Source§

fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
where Self: Sized, R: Try<Output = bool>, <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬This is a nightly-only experimental API. (try_find)
Applies function to the elements of iterator and returns the first true result or the first error. Read more
1.0.0 · Source§

fn position<P>(&mut self, predicate: P) -> Option<usize>
where Self: Sized, P: FnMut(Self::Item) -> bool,

Searches for an element in an iterator, returning its index. Read more
1.0.0 · Source§

fn max(self) -> Option<Self::Item>
where Self: Sized, Self::Item: Ord,

Returns the maximum element of an iterator. Read more
1.0.0 · Source§

fn min(self) -> Option<Self::Item>
where Self: Sized, Self::Item: Ord,

Returns the minimum element of an iterator. Read more
1.6.0 · Source§

fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,

Returns the element that gives the maximum value from the specified function. Read more
1.15.0 · Source§

fn max_by<F>(self, compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

Returns the element that gives the maximum value with respect to the specified comparison function. Read more
1.6.0 · Source§

fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,

Returns the element that gives the minimum value from the specified function. Read more
1.15.0 · Source§

fn min_by<F>(self, compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

Returns the element that gives the minimum value with respect to the specified comparison function. Read more
1.0.0 · Source§

fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Sized + Iterator<Item = (A, B)>,

Converts an iterator of pairs into a pair of containers. Read more
1.36.0 · Source§

fn copied<'a, T>(self) -> Copied<Self>
where T: 'a + Copy, Self: Sized + Iterator<Item = &'a T>,

Creates an iterator which copies all of its elements. Read more
1.0.0 · Source§

fn cloned<'a, T>(self) -> Cloned<Self>
where T: 'a + Clone, Self: Sized + Iterator<Item = &'a T>,

Creates an iterator which clones all of its elements. Read more
1.0.0 · Source§

fn cycle(self) -> Cycle<Self>
where Self: Sized + Clone,

Repeats an iterator endlessly. Read more
Source§

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
where Self: Sized,

🔬This is a nightly-only experimental API. (iter_array_chunks)
Returns an iterator over N elements of the iterator at a time. Read more
1.11.0 · Source§

fn sum<S>(self) -> S
where Self: Sized, S: Sum<Self::Item>,

Sums the elements of an iterator. Read more
1.11.0 · Source§

fn product<P>(self) -> P
where Self: Sized, P: Product<Self::Item>,

Iterates over the entire iterator, multiplying all the elements Read more
1.5.0 · Source§

fn cmp<I>(self, other: I) -> Ordering
where I: IntoIterator<Item = Self::Item>, Self::Item: Ord, Self: Sized,

Lexicographically compares the elements of this Iterator with those of another. Read more
Source§

fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,

🔬This is a nightly-only experimental API. (iter_order_by)
Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function. Read more
1.5.0 · Source§

fn partial_cmp<I>(self, other: I) -> Option<Ordering>
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

Lexicographically compares the PartialOrd elements of this Iterator with those of another. The comparison works like short-circuit evaluation, returning a result without comparing the remaining elements. As soon as an order can be determined, the evaluation stops and a result is returned. Read more
Source§

fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,

🔬This is a nightly-only experimental API. (iter_order_by)
Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function. Read more
1.5.0 · Source§

fn eq<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are equal to those of another. Read more
Source§

fn eq_by<I, F>(self, other: I, eq: F) -> bool
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,

🔬This is a nightly-only experimental API. (iter_order_by)
Determines if the elements of this Iterator are equal to those of another with respect to the specified equality function. Read more
1.5.0 · Source§

fn ne<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are not equal to those of another. Read more
1.5.0 · Source§

fn lt<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are lexicographically less than those of another. Read more
1.5.0 · Source§

fn le<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are lexicographically less or equal to those of another. Read more
1.5.0 · Source§

fn gt<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are lexicographically greater than those of another. Read more
1.5.0 · Source§

fn ge<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

Determines if the elements of this Iterator are lexicographically greater than or equal to those of another. Read more
1.82.0 · Source§

fn is_sorted(self) -> bool
where Self: Sized, Self::Item: PartialOrd,

Checks if the elements of this iterator are sorted. Read more
1.82.0 · Source§

fn is_sorted_by<F>(self, compare: F) -> bool
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> bool,

Checks if the elements of this iterator are sorted using the given comparator function. Read more
1.82.0 · Source§

fn is_sorted_by_key<F, K>(self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> K, K: PartialOrd,

Checks if the elements of this iterator are sorted using the given key extraction function. Read more
Source§

impl<'py> Mul<&Bound<'py, PyComplex>> for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the * operation. Read more
Source§

impl<'py> Mul<Bound<'py, PyComplex>> for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the * operation. Read more
Source§

impl<'py> Mul for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the * operation. Read more
Source§

impl<'py> Mul for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the * operation. Read more
Source§

impl<'py> Neg for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Bound<'py, PyComplex>

Performs the unary - operation. Read more
Source§

impl<'py> Neg for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Bound<'py, PyComplex>

Performs the unary - operation. Read more
Source§

impl PartialEq<&[u8]> for Bound<'_, PyBytes>

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &&[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Bound<'_, PyBool>> for bool

Compare bool with &Bound<PyBool>

Source§

fn eq(&self, other: &&Bound<'_, PyBool>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Bound<'_, PyBytes>> for [u8]

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &&Bound<'_, PyBytes>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Bound<'_, PyFloat>> for f32

Source§

fn eq(&self, other: &&Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Bound<'_, PyFloat>> for f64

Source§

fn eq(&self, other: &&Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Bound<'_, PyString>> for str

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &&Bound<'_, PyString>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&bool> for Bound<'_, PyBool>

Compare Bound<PyBool> with &bool.

Source§

fn eq(&self, other: &&bool) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&f32> for Bound<'_, PyFloat>

Source§

fn eq(&self, other: &&f32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&f64> for Bound<'_, PyFloat>

Source§

fn eq(&self, other: &&f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for Bound<'_, PyString>

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for &Bound<'_, PyBytes>

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for Bound<'_, PyBytes>

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyBool>> for &bool

Compare &bool with Bound<PyBool>

Source§

fn eq(&self, other: &Bound<'_, PyBool>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyBool>> for bool

Compare bool with Bound<PyBool>

Source§

fn eq(&self, other: &Bound<'_, PyBool>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyBytes>> for &[u8]

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &Bound<'_, PyBytes>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyBytes>> for [u8]

Compares whether the Python bytes object is equal to the u8.

In some cases Python equality might be more appropriate; see the note on PyBytes.

Source§

fn eq(&self, other: &Bound<'_, PyBytes>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyFloat>> for &f32

Source§

fn eq(&self, other: &Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyFloat>> for &f64

Source§

fn eq(&self, other: &Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyFloat>> for f32

Source§

fn eq(&self, other: &Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyFloat>> for f64

Source§

fn eq(&self, other: &Bound<'_, PyFloat>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for i128

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for i16

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for i32

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for i64

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for i8

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for isize

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for u128

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for u16

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for u32

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for u64

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for u8

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyInt>> for usize

Source§

fn eq(&self, other: &Bound<'_, PyInt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyString>> for &str

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &Bound<'_, PyString>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Bound<'_, PyString>> for str

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &Bound<'_, PyString>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<bool> for &Bound<'_, PyBool>

Compare &Bound<PyBool> with bool.

Source§

fn eq(&self, other: &bool) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<bool> for Bound<'_, PyBool>

Compare Bound<PyBool> with bool.

Source§

fn eq(&self, other: &bool) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f32> for &Bound<'_, PyFloat>

Source§

fn eq(&self, other: &f32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f32> for Bound<'_, PyFloat>

Source§

fn eq(&self, other: &f32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for &Bound<'_, PyFloat>

Source§

fn eq(&self, other: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for Bound<'_, PyFloat>

Source§

fn eq(&self, other: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i128> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &i128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i16> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &i16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i32> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &i32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i64> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &i64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i8> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &i8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<isize> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &isize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for &Bound<'_, PyString>

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for Bound<'_, PyString>

Compares whether the data in the Python string is equal to the given UTF8.

In some cases Python equality might be more appropriate; see the note on PyString.

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u128> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &u128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u16> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &u16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u32> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u64> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &u64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u8> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &u8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<usize> for Bound<'_, PyInt>

Source§

fn eq(&self, other: &usize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'py> PyAnyMethods<'py> for Bound<'py, PyAny>

Source§

fn add<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self + other.

Source§

fn sub<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self - other.

Source§

fn mul<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self * other.

Source§

fn matmul<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self @ other.

Source§

fn div<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self / other.

Source§

fn floor_div<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self // other.

Source§

fn rem<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self % other.

Source§

fn lshift<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self << other.

Source§

fn rshift<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self >> other.

Source§

fn bitand<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self & other.

Source§

fn bitor<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self | other.

Source§

fn bitxor<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes self ^ other.

Source§

fn divmod<O>(&self, other: O) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Computes divmod(self, other).

Source§

fn pow<O1, O2>(&self, other: O1, modulus: O2) -> PyResult<Bound<'py, PyAny>>
where O1: IntoPyObject<'py>, O2: IntoPyObject<'py>,

Computes self ** other % modulus (pow(self, other, modulus)). py.None() may be passed for the modulus.

Source§

fn is<T: AsPyPointer>(&self, other: &T) -> bool

Returns whether self and other point to the same object. To compare the equality of two objects (the == operator), use eq. Read more
Source§

fn hasattr<N>(&self, attr_name: N) -> PyResult<bool>
where N: IntoPyObject<'py, Target = PyString>,

Determines whether this object has the given attribute. Read more
Source§

fn getattr<N>(&self, attr_name: N) -> PyResult<Bound<'py, PyAny>>
where N: IntoPyObject<'py, Target = PyString>,

Retrieves an attribute value. Read more
Source§

fn setattr<N, V>(&self, attr_name: N, value: V) -> PyResult<()>
where N: IntoPyObject<'py, Target = PyString>, V: IntoPyObject<'py>,

Sets an attribute value. Read more
Source§

fn delattr<N>(&self, attr_name: N) -> PyResult<()>
where N: IntoPyObject<'py, Target = PyString>,

Deletes an attribute. Read more
Source§

fn compare<O>(&self, other: O) -> PyResult<Ordering>
where O: IntoPyObject<'py>,

Returns an Ordering between self and other. Read more
Source§

fn rich_compare<O>( &self, other: O, compare_op: CompareOp, ) -> PyResult<Bound<'py, PyAny>>
where O: IntoPyObject<'py>,

Tests whether two Python objects obey a given CompareOp. Read more
Source§

fn neg(&self) -> PyResult<Bound<'py, PyAny>>

Computes the negative of self. Read more
Source§

fn pos(&self) -> PyResult<Bound<'py, PyAny>>

Computes the positive of self. Read more
Source§

fn abs(&self) -> PyResult<Bound<'py, PyAny>>

Computes the absolute of self. Read more
Source§

fn bitnot(&self) -> PyResult<Bound<'py, PyAny>>

Computes ~self.
Source§

fn lt<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is less than another. Read more
Source§

fn le<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is less than or equal to another. Read more
Source§

fn eq<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is equal to another. Read more
Source§

fn ne<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is not equal to another. Read more
Source§

fn gt<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is greater than another. Read more
Source§

fn ge<O>(&self, other: O) -> PyResult<bool>
where O: IntoPyObject<'py>,

Tests whether this object is greater than or equal to another. Read more
Source§

fn is_callable(&self) -> bool

Determines whether this object appears callable. Read more
Source§

fn call<A>( &self, args: A, kwargs: Option<&Bound<'py, PyDict>>, ) -> PyResult<Bound<'py, PyAny>>
where A: IntoPyObject<'py, Target = PyTuple>,

Calls the object. Read more
Source§

fn call0(&self) -> PyResult<Bound<'py, PyAny>>

Calls the object without arguments. Read more
Source§

fn call1<A>(&self, args: A) -> PyResult<Bound<'py, PyAny>>
where A: IntoPyObject<'py, Target = PyTuple>,

Calls the object with only positional arguments. Read more
Source§

fn call_method<N, A>( &self, name: N, args: A, kwargs: Option<&Bound<'py, PyDict>>, ) -> PyResult<Bound<'py, PyAny>>
where N: IntoPyObject<'py, Target = PyString>, A: IntoPyObject<'py, Target = PyTuple>,

Calls a method on the object. Read more
Source§

fn call_method0<N>(&self, name: N) -> PyResult<Bound<'py, PyAny>>
where N: IntoPyObject<'py, Target = PyString>,

Calls a method on the object without arguments. Read more
Source§

fn call_method1<N, A>(&self, name: N, args: A) -> PyResult<Bound<'py, PyAny>>
where N: IntoPyObject<'py, Target = PyString>, A: IntoPyObject<'py, Target = PyTuple>,

Calls a method on the object with only positional arguments. Read more
Source§

fn is_truthy(&self) -> PyResult<bool>

Returns whether the object is considered to be true. Read more
Source§

fn is_none(&self) -> bool

Returns whether the object is considered to be None. Read more
Source§

fn is_ellipsis(&self) -> bool

👎Deprecated since 0.23.0: use .is(py.Ellipsis()) instead
Returns whether the object is Ellipsis, e.g. .... Read more
Source§

fn is_empty(&self) -> PyResult<bool>

Returns true if the sequence or mapping has a length of 0. Read more
Source§

fn get_item<K>(&self, key: K) -> PyResult<Bound<'py, PyAny>>
where K: IntoPyObject<'py>,

Gets an item from the collection. Read more
Source§

fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()>
where K: IntoPyObject<'py>, V: IntoPyObject<'py>,

Sets a collection item value. Read more
Source§

fn del_item<K>(&self, key: K) -> PyResult<()>
where K: IntoPyObject<'py>,

Deletes an item from the collection. Read more
Source§

fn try_iter(&self) -> PyResult<Bound<'py, PyIterator>>

Takes an object and returns an iterator for it. Returns an error if the object is not iterable. Read more
Source§

fn iter(&self) -> PyResult<Bound<'py, PyIterator>>

👎Deprecated since 0.23.0: use try_iter instead
Takes an object and returns an iterator for it. Read more
Source§

fn get_type(&self) -> Bound<'py, PyType>

Returns the Python type object for this object’s type.
Source§

fn get_type_ptr(&self) -> *mut PyTypeObject

Returns the Python type pointer for this object.
Source§

fn downcast<T>(&self) -> Result<&Bound<'py, T>, DowncastError<'_, 'py>>
where T: PyTypeCheck,

Downcast this PyAny to a concrete Python type or pyclass. Read more
Source§

fn downcast_into<T>(self) -> Result<Bound<'py, T>, DowncastIntoError<'py>>
where T: PyTypeCheck,

Like downcast but takes ownership of self. Read more
Source§

fn downcast_exact<T>(&self) -> Result<&Bound<'py, T>, DowncastError<'_, 'py>>
where T: PyTypeInfo,

Downcast this PyAny to a concrete Python type or pyclass (but not a subclass of it). Read more
Source§

fn downcast_into_exact<T>(self) -> Result<Bound<'py, T>, DowncastIntoError<'py>>
where T: PyTypeInfo,

Like downcast_exact but takes ownership of self.
Source§

unsafe fn downcast_unchecked<T>(&self) -> &Bound<'py, T>

Converts this PyAny to a concrete Python type without checking validity. Read more
Source§

unsafe fn downcast_into_unchecked<T>(self) -> Bound<'py, T>

Like downcast_unchecked but takes ownership of self. Read more
Source§

fn extract<'a, T>(&'a self) -> PyResult<T>
where T: FromPyObjectBound<'a, 'py>,

Extracts some type from the Python object. Read more
Source§

fn get_refcnt(&self) -> isize

Returns the reference count for the Python object.
Source§

fn repr(&self) -> PyResult<Bound<'py, PyString>>

Computes the “repr” representation of self. Read more
Source§

fn str(&self) -> PyResult<Bound<'py, PyString>>

Computes the “str” representation of self. Read more
Source§

fn hash(&self) -> PyResult<isize>

Retrieves the hash code of self. Read more
Source§

fn len(&self) -> PyResult<usize>

Returns the length of the sequence or mapping. Read more
Source§

fn dir(&self) -> PyResult<Bound<'py, PyList>>

Returns the list of attributes of this object. Read more
Source§

fn is_instance(&self, ty: &Bound<'py, PyAny>) -> PyResult<bool>

Checks whether this object is an instance of type ty. Read more
Source§

fn is_exact_instance(&self, ty: &Bound<'py, PyAny>) -> bool

Checks whether this object is an instance of exactly type ty (not a subclass). Read more
Source§

fn is_instance_of<T: PyTypeInfo>(&self) -> bool

Checks whether this object is an instance of type T. Read more
Source§

fn is_exact_instance_of<T: PyTypeInfo>(&self) -> bool

Checks whether this object is an instance of exactly type T. Read more
Source§

fn contains<V>(&self, value: V) -> PyResult<bool>
where V: IntoPyObject<'py>,

Determines if self contains value. Read more
Source§

fn py_super(&self) -> PyResult<Bound<'py, PySuper>>

Return a proxy object that delegates method calls to a parent or sibling class of type. Read more
Source§

impl<'py> PyBoolMethods<'py> for Bound<'py, PyBool>

Source§

fn is_true(&self) -> bool

Gets whether this boolean is true.
Source§

impl<'py> PyByteArrayMethods<'py> for Bound<'py, PyByteArray>

Source§

fn len(&self) -> usize

Gets the length of the bytearray.
Source§

fn is_empty(&self) -> bool

Checks if the bytearray is empty.
Source§

fn data(&self) -> *mut u8

Gets the start of the buffer containing the contents of the bytearray. Read more
Source§

unsafe fn as_bytes(&self) -> &[u8]

Extracts a slice of the ByteArray’s entire buffer. Read more
Source§

unsafe fn as_bytes_mut(&self) -> &mut [u8]

Extracts a mutable slice of the ByteArray’s entire buffer. Read more
Source§

fn to_vec(&self) -> Vec<u8>

Copies the contents of the bytearray to a Rust vector. Read more
Source§

fn resize(&self, len: usize) -> PyResult<()>

Resizes the bytearray object to the new length len. Read more
Source§

impl<'py> PyBytesMethods<'py> for Bound<'py, PyBytes>

Source§

fn as_bytes(&self) -> &[u8]

Gets the Python string as a byte slice.
Source§

impl<'py> PyCapsuleMethods<'py> for Bound<'py, PyCapsule>

Source§

fn set_context(&self, context: *mut c_void) -> PyResult<()>

Sets the context pointer in the capsule. Read more
Source§

fn context(&self) -> PyResult<*mut c_void>

Gets the current context stored in the capsule. If there is no context, the pointer will be null. Read more
Source§

unsafe fn reference<T>(&self) -> &'py T

Obtains a reference to the value of this capsule. Read more
Source§

fn pointer(&self) -> *mut c_void

Gets the raw c_void pointer to the value in this capsule. Read more
Source§

fn is_valid(&self) -> bool

Checks if this is a valid capsule. Read more
Source§

fn name(&self) -> PyResult<Option<&'py CStr>>

Retrieves the name of this capsule, if set. Read more
Source§

impl<'py> PyComplexMethods<'py> for Bound<'py, PyComplex>

Source§

fn real(&self) -> c_double

Returns the real part of the complex number.
Source§

fn imag(&self) -> c_double

Returns the imaginary part of the complex number.
Source§

fn abs(&self) -> c_double

Returns |self|.
Source§

fn pow(&self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Returns self raised to the power of other.
Source§

impl PyDateAccess for Bound<'_, PyDate>

Source§

fn get_year(&self) -> i32

Returns the year, as a positive int. Read more
Source§

fn get_month(&self) -> u8

Returns the month, as an int from 1 through 12. Read more
Source§

fn get_day(&self) -> u8

Returns the day, as an int from 1 through 31. Read more
Source§

impl PyDateAccess for Bound<'_, PyDateTime>

Source§

fn get_year(&self) -> i32

Returns the year, as a positive int. Read more
Source§

fn get_month(&self) -> u8

Returns the month, as an int from 1 through 12. Read more
Source§

fn get_day(&self) -> u8

Returns the day, as an int from 1 through 31. Read more
Source§

impl PyDeltaAccess for Bound<'_, PyDelta>

Source§

fn get_days(&self) -> i32

Returns the number of days, as an int from -999999999 to 999999999. Read more
Source§

fn get_seconds(&self) -> i32

Returns the number of seconds, as an int from 0 through 86399. Read more
Source§

fn get_microseconds(&self) -> i32

Returns the number of microseconds, as an int from 0 through 999999. Read more
Source§

impl<'py> PyDictMethods<'py> for Bound<'py, PyDict>

Source§

fn copy(&self) -> PyResult<Bound<'py, PyDict>>

Returns a new dictionary that contains the same key-value pairs as self. Read more
Source§

fn clear(&self)

Empties an existing dictionary of all key-value pairs.
Source§

fn len(&self) -> usize

Return the number of items in the dictionary. Read more
Source§

fn is_empty(&self) -> bool

Checks if the dict is empty, i.e. len(self) == 0.
Source§

fn contains<K>(&self, key: K) -> PyResult<bool>
where K: IntoPyObject<'py>,

Determines if the dictionary contains the specified key. Read more
Source§

fn get_item<K>(&self, key: K) -> PyResult<Option<Bound<'py, PyAny>>>
where K: IntoPyObject<'py>,

Gets an item from the dictionary. Read more
Source§

fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()>
where K: IntoPyObject<'py>, V: IntoPyObject<'py>,

Sets an item value. Read more
Source§

fn del_item<K>(&self, key: K) -> PyResult<()>
where K: IntoPyObject<'py>,

Deletes an item. Read more
Source§

fn keys(&self) -> Bound<'py, PyList>

Returns a list of dict keys. Read more
Source§

fn values(&self) -> Bound<'py, PyList>

Returns a list of dict values. Read more
Source§

fn items(&self) -> Bound<'py, PyList>

Returns a list of dict items. Read more
Source§

fn iter(&self) -> BoundDictIterator<'py>

Returns an iterator of (key, value) pairs in this dictionary. Read more
Source§

fn locked_for_each<F>(&self, f: F) -> PyResult<()>
where F: Fn(Bound<'py, PyAny>, Bound<'py, PyAny>) -> PyResult<()>,

Iterates over the contents of this dictionary while holding a critical section on the dict. This is useful when the GIL is disabled and the dictionary is shared between threads. It is not guaranteed that the dictionary will not be modified during iteration when the closure calls arbitrary Python code that releases the current critical section. Read more
Source§

fn as_mapping(&self) -> &Bound<'py, PyMapping>

Returns self cast as a PyMapping.
Source§

fn into_mapping(self) -> Bound<'py, PyMapping>

Returns self cast as a PyMapping.
Source§

fn update(&self, other: &Bound<'_, PyMapping>) -> PyResult<()>

Update this dictionary with the key/value pairs from another. Read more
Source§

fn update_if_missing(&self, other: &Bound<'_, PyMapping>) -> PyResult<()>

Add key/value pairs from another dictionary to this one only when they do not exist in this. Read more
Source§

impl<'py> PyFloatMethods<'py> for Bound<'py, PyFloat>

Source§

fn value(&self) -> c_double

Gets the value of this float.
Source§

impl<'py> PyFrozenSetMethods<'py> for Bound<'py, PyFrozenSet>

Source§

fn len(&self) -> usize

Returns the number of items in the set. Read more
Source§

fn contains<K>(&self, key: K) -> PyResult<bool>
where K: IntoPyObject<'py>,

Determines if the set contains the specified key. Read more
Source§

fn iter(&self) -> BoundFrozenSetIterator<'py>

Returns an iterator of values in this set.
Source§

fn is_empty(&self) -> bool

Checks if set is empty.
Source§

impl<'py> PyListMethods<'py> for Bound<'py, PyList>

Source§

fn len(&self) -> usize

Returns the length of the list.

Source§

fn is_empty(&self) -> bool

Checks if the list is empty.

Source§

fn as_sequence(&self) -> &Bound<'py, PySequence>

Returns self cast as a PySequence.

Source§

fn into_sequence(self) -> Bound<'py, PySequence>

Returns self cast as a PySequence.

Source§

fn get_item(&self, index: usize) -> PyResult<Bound<'py, PyAny>>

Gets the list item at the specified index.

§Example
use pyo3::{prelude::*, types::PyList};
Python::with_gil(|py| {
    let list = PyList::new(py, [2, 3, 5, 7]).unwrap();
    let obj = list.get_item(0);
    assert_eq!(obj.unwrap().extract::<i32>().unwrap(), 2);
});
Source§

unsafe fn get_item_unchecked(&self, index: usize) -> Bound<'py, PyAny>

Gets the list item at the specified index. Undefined behavior on bad index. Use with caution.

§Safety

Caller must verify that the index is within the bounds of the list.

Source§

fn get_slice(&self, low: usize, high: usize) -> Bound<'py, PyList>

Takes the slice self[low:high] and returns it as a new list.

Indices must be nonnegative, and out-of-range indices are clipped to self.len().

Source§

fn set_item<I>(&self, index: usize, item: I) -> PyResult<()>
where I: IntoPyObject<'py>,

Sets the item at the specified index.

Raises IndexError if the index is out of range.

Source§

fn del_item(&self, index: usize) -> PyResult<()>

Deletes the indexth element of self.

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

Source§

fn set_slice( &self, low: usize, high: usize, seq: &Bound<'_, PyAny>, ) -> PyResult<()>

Assigns the sequence seq to the slice of self from low to high.

This is equivalent to the Python statement self[low:high] = v.

Source§

fn del_slice(&self, low: usize, high: usize) -> PyResult<()>

Deletes the slice from low to high from self.

This is equivalent to the Python statement del self[low:high].

Source§

fn append<I>(&self, item: I) -> PyResult<()>
where I: IntoPyObject<'py>,

Appends an item to the list.

Source§

fn insert<I>(&self, index: usize, item: I) -> PyResult<()>
where I: IntoPyObject<'py>,

Inserts an item at the specified index.

If index >= self.len(), inserts at the end.

Source§

fn contains<V>(&self, value: V) -> PyResult<bool>
where V: IntoPyObject<'py>,

Determines if self contains value.

This is equivalent to the Python expression value in self.

Source§

fn index<V>(&self, value: V) -> PyResult<usize>
where V: IntoPyObject<'py>,

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

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

Source§

fn iter(&self) -> BoundListIterator<'py>

Returns an iterator over this list’s items.

Source§

fn sort(&self) -> PyResult<()>

Sorts the list in-place. Equivalent to the Python expression l.sort().

Source§

fn reverse(&self) -> PyResult<()>

Reverses the list in-place. Equivalent to the Python expression l.reverse().

Source§

fn to_tuple(&self) -> Bound<'py, PyTuple>

Return a new tuple containing the contents of the list; equivalent to the Python expression tuple(list).

This method is equivalent to self.as_sequence().to_tuple() and faster than PyTuple::new(py, this_list).

Source§

impl<'py> PyMappingMethods<'py> for Bound<'py, PyMapping>

Source§

fn len(&self) -> PyResult<usize>

Returns the number of objects in the mapping. Read more
Source§

fn is_empty(&self) -> PyResult<bool>

Returns whether the mapping is empty.
Source§

fn contains<K>(&self, key: K) -> PyResult<bool>
where K: IntoPyObject<'py>,

Determines if the mapping contains the specified key. Read more
Source§

fn get_item<K>(&self, key: K) -> PyResult<Bound<'py, PyAny>>
where K: IntoPyObject<'py>,

Gets the item in self with key key. Read more
Source§

fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()>
where K: IntoPyObject<'py>, V: IntoPyObject<'py>,

Sets the item in self with key key. Read more
Source§

fn del_item<K>(&self, key: K) -> PyResult<()>
where K: IntoPyObject<'py>,

Deletes the item with key key. Read more
Source§

fn keys(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all keys in the mapping.
Source§

fn values(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all values in the mapping.
Source§

fn items(&self) -> PyResult<Bound<'py, PyList>>

Returns a list of all (key, value) pairs in the mapping.
Source§

impl<'py, 'a> PyMappingProxyMethods<'py, 'a> for Bound<'py, PyMappingProxy>

Source§

fn is_empty(&self) -> PyResult<bool>

Checks if the mappingproxy is empty, i.e. len(self) == 0.
Source§

fn keys(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all keys in the mapping.
Source§

fn values(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all values in the mapping.
Source§

fn items(&self) -> PyResult<Bound<'py, PyList>>

Returns a list of tuples of all (key, value) pairs in the mapping.
Source§

fn as_mapping(&self) -> &Bound<'py, PyMapping>

Returns self cast as a PyMapping.
Source§

fn try_iter(&'a self) -> PyResult<BoundMappingProxyIterator<'py, 'a>>

Takes an object and returns an iterator for it. Returns an error if the object is not iterable.
Source§

impl<'py> PyModuleMethods<'py> for Bound<'py, PyModule>

Source§

fn dict(&self) -> Bound<'py, PyDict>

Returns the module’s __dict__ attribute, which contains the module’s symbol table.
Source§

fn index(&self) -> PyResult<Bound<'py, PyList>>

Returns the index (the __all__ attribute) of the module, creating one if needed. Read more
Source§

fn name(&self) -> PyResult<Bound<'py, PyString>>

Returns the name (the __name__ attribute) of the module. Read more
Source§

fn filename(&self) -> PyResult<Bound<'py, PyString>>

Returns the filename (the __file__ attribute) of the module. Read more
Source§

fn add<N, V>(&self, name: N, value: V) -> PyResult<()>
where N: IntoPyObject<'py, Target = PyString>, V: IntoPyObject<'py>,

Adds an attribute to the module. Read more
Source§

fn add_class<T>(&self) -> PyResult<()>
where T: PyClass,

Adds a new class to the module. Read more
Source§

fn add_wrapped<T>(&self, wrapper: &impl Fn(Python<'py>) -> T) -> PyResult<()>
where T: IntoPyCallbackOutput<'py, PyObject>,

Adds a function or a (sub)module to a module, using the functions name as name. Read more
Source§

fn add_submodule(&self, module: &Bound<'_, PyModule>) -> PyResult<()>

Adds a submodule to a module. Read more
Source§

fn add_function(&self, fun: Bound<'_, PyCFunction>) -> PyResult<()>

Add a function to a module. Read more
Source§

fn gil_used(&self, gil_used: bool) -> PyResult<()>

Declare whether or not this module supports running with the GIL disabled Read more
Source§

impl<'py> PySequenceMethods<'py> for Bound<'py, PySequence>

Source§

fn len(&self) -> PyResult<usize>

Returns the number of objects in sequence. Read more
Source§

fn is_empty(&self) -> PyResult<bool>

Returns whether the sequence is empty.
Source§

fn concat( &self, other: &Bound<'_, PySequence>, ) -> PyResult<Bound<'py, PySequence>>

Returns the concatenation of self and other. Read more
Source§

fn repeat(&self, count: usize) -> PyResult<Bound<'py, PySequence>>

Returns the result of repeating a sequence object count times. Read more
Source§

fn in_place_concat( &self, other: &Bound<'_, PySequence>, ) -> PyResult<Bound<'py, PySequence>>

Concatenates self and other, in place if possible. Read more
Source§

fn in_place_repeat(&self, count: usize) -> PyResult<Bound<'py, PySequence>>

Repeats the sequence object count times and updates self, if possible. Read more
Source§

fn get_item(&self, index: usize) -> PyResult<Bound<'py, PyAny>>

Returns the indexth element of the Sequence. Read more
Source§

fn get_slice( &self, begin: usize, end: usize, ) -> PyResult<Bound<'py, PySequence>>

Returns the slice of sequence object between begin and end. Read more
Source§

fn set_item<I>(&self, i: usize, item: I) -> PyResult<()>
where I: IntoPyObject<'py>,

Assigns object item to the ith element of self. Read more
Source§

fn del_item(&self, i: usize) -> PyResult<()>

Deletes the ith element of self. Read more
Source§

fn set_slice(&self, i1: usize, i2: usize, v: &Bound<'_, PyAny>) -> PyResult<()>

Assigns the sequence v to the slice of self from i1 to i2. Read more
Source§

fn del_slice(&self, i1: usize, i2: usize) -> PyResult<()>

Deletes the slice from i1 to i2 from self. Read more
Source§

fn count<V>(&self, value: V) -> PyResult<usize>
where V: IntoPyObject<'py>,

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

fn contains<V>(&self, value: V) -> PyResult<bool>
where V: IntoPyObject<'py>,

Determines if self contains value. Read more
Source§

fn index<V>(&self, value: V) -> PyResult<usize>
where V: IntoPyObject<'py>,

Returns the first index i for which self[i] == value. Read more
Source§

fn to_list(&self) -> PyResult<Bound<'py, PyList>>

Returns a fresh list based on the Sequence.
Source§

fn to_tuple(&self) -> PyResult<Bound<'py, PyTuple>>

Returns a fresh tuple based on the Sequence.
Source§

impl<'py> PySetMethods<'py> for Bound<'py, PySet>

Source§

fn clear(&self)

Removes all elements from the set.
Source§

fn len(&self) -> usize

Returns the number of items in the set. Read more
Source§

fn contains<K>(&self, key: K) -> PyResult<bool>
where K: IntoPyObject<'py>,

Determines if the set contains the specified key. Read more
Source§

fn discard<K>(&self, key: K) -> PyResult<bool>
where K: IntoPyObject<'py>,

Removes the element from the set if it is present. Read more
Source§

fn add<K>(&self, key: K) -> PyResult<()>
where K: IntoPyObject<'py>,

Adds an element to the set.
Source§

fn pop(&self) -> Option<Bound<'py, PyAny>>

Removes and returns an arbitrary element from the set.
Source§

fn iter(&self) -> BoundSetIterator<'py>

Returns an iterator of values in this set. Read more
Source§

fn is_empty(&self) -> bool

Checks if set is empty.
Source§

impl<'py> PySliceMethods<'py> for Bound<'py, PySlice>

Source§

fn indices(&self, length: isize) -> PyResult<PySliceIndices>

Retrieves the start, stop, and step indices from the slice object, assuming a sequence of length length, and stores the length of the slice in its slicelength member.
Source§

impl<'py> PyStringMethods<'py> for Bound<'py, PyString>

Source§

fn to_str(&self) -> PyResult<&str>

Gets the Python string as a Rust UTF-8 string slice. Read more
Source§

fn to_cow(&self) -> PyResult<Cow<'_, str>>

Converts the PyString into a Rust string, avoiding copying when possible. Read more
Source§

fn to_string_lossy(&self) -> Cow<'_, str>

Converts the PyString into a Rust string. Read more
Source§

fn encode_utf8(&self) -> PyResult<Bound<'py, PyBytes>>

Encodes this string as a Python bytes object, using UTF-8 encoding.
Source§

unsafe fn data(&self) -> PyResult<PyStringData<'_>>

Obtains the raw data backing the Python string. Read more
Source§

impl PyTimeAccess for Bound<'_, PyDateTime>

Source§

fn get_hour(&self) -> u8

Returns the hour, as an int from 0 through 23. Read more
Source§

fn get_minute(&self) -> u8

Returns the minute, as an int from 0 through 59. Read more
Source§

fn get_second(&self) -> u8

Returns the second, as an int from 0 through 59. Read more
Source§

fn get_microsecond(&self) -> u32

Returns the microsecond, as an int from 0 through 999999. Read more
Source§

fn get_fold(&self) -> bool

Returns whether this date is the later of two moments with the same representation, during a repeated interval. Read more
Source§

impl PyTimeAccess for Bound<'_, PyTime>

Source§

fn get_hour(&self) -> u8

Returns the hour, as an int from 0 through 23. Read more
Source§

fn get_minute(&self) -> u8

Returns the minute, as an int from 0 through 59. Read more
Source§

fn get_second(&self) -> u8

Returns the second, as an int from 0 through 59. Read more
Source§

fn get_microsecond(&self) -> u32

Returns the microsecond, as an int from 0 through 999999. Read more
Source§

fn get_fold(&self) -> bool

Returns whether this date is the later of two moments with the same representation, during a repeated interval. Read more
Source§

impl<'py> PyTracebackMethods<'py> for Bound<'py, PyTraceback>

Source§

fn format(&self) -> PyResult<String>

Formats the traceback as a string. Read more
Source§

impl<'py> PyTupleMethods<'py> for Bound<'py, PyTuple>

Source§

fn len(&self) -> usize

Gets the length of the tuple.
Source§

fn is_empty(&self) -> bool

Checks if the tuple is empty.
Source§

fn as_sequence(&self) -> &Bound<'py, PySequence>

Returns self cast as a PySequence.
Source§

fn into_sequence(self) -> Bound<'py, PySequence>

Returns self cast as a PySequence.
Source§

fn get_slice(&self, low: usize, high: usize) -> Bound<'py, PyTuple>

Takes the slice self[low:high] and returns it as a new tuple. Read more
Source§

fn get_item(&self, index: usize) -> PyResult<Bound<'py, PyAny>>

Gets the tuple item at the specified index. Read more
Source§

fn get_borrowed_item<'a>( &'a self, index: usize, ) -> PyResult<Borrowed<'a, 'py, PyAny>>

Like get_item, but returns a borrowed object, which is a slight performance optimization by avoiding a reference count change.
Source§

unsafe fn get_item_unchecked(&self, index: usize) -> Bound<'py, PyAny>

Gets the tuple item at the specified index. Undefined behavior on bad index. Use with caution. Read more
Source§

unsafe fn get_borrowed_item_unchecked<'a>( &'a self, index: usize, ) -> Borrowed<'a, 'py, PyAny>

Like get_item_unchecked, but returns a borrowed object, which is a slight performance optimization by avoiding a reference count change. Read more
Source§

fn as_slice(&self) -> &[Bound<'py, PyAny>]

Returns self as a slice of objects.
Source§

fn contains<V>(&self, value: V) -> PyResult<bool>
where V: IntoPyObject<'py>,

Determines if self contains value. Read more
Source§

fn index<V>(&self, value: V) -> PyResult<usize>
where V: IntoPyObject<'py>,

Returns the first index i for which self[i] == value. Read more
Source§

fn iter(&self) -> BoundTupleIterator<'py>

Returns an iterator over the tuple items.
Source§

fn iter_borrowed<'a>(&'a self) -> BorrowedTupleIterator<'a, 'py>

Like iter, but produces an iterator which returns borrowed objects, which is a slight performance optimization by avoiding a reference count change.
Source§

fn to_list(&self) -> Bound<'py, PyList>

Return a new list containing the contents of this tuple; equivalent to the Python expression list(tuple). Read more
Source§

impl<'py> PyTypeMethods<'py> for Bound<'py, PyType>

Source§

fn as_type_ptr(&self) -> *mut PyTypeObject

Retrieves the underlying FFI pointer associated with this Python object.

Source§

fn name(&self) -> PyResult<Bound<'py, PyString>>

Gets the name of the PyType.

Source§

fn qualname(&self) -> PyResult<Bound<'py, PyString>>

Gets the qualified name of the PyType.

Source§

fn module(&self) -> PyResult<Bound<'py, PyString>>

Gets the name of the module defining the PyType.

Source§

fn fully_qualified_name(&self) -> PyResult<Bound<'py, PyString>>

Gets the fully qualified name of the PyType.

Source§

fn is_subclass(&self, other: &Bound<'_, PyAny>) -> PyResult<bool>

Checks whether self is a subclass of other.

Equivalent to the Python expression issubclass(self, other).

Source§

fn is_subclass_of<T>(&self) -> PyResult<bool>
where T: PyTypeInfo,

Checks whether self is a subclass of type T.

Equivalent to the Python expression issubclass(self, T), if the type T is known at compile time.

Source§

fn mro(&self) -> Bound<'py, PyTuple>

Return the method resolution order for this type. Read more
Source§

fn bases(&self) -> Bound<'py, PyTuple>

Return Python bases Read more
Source§

impl<'py> PyTzInfoAccess<'py> for Bound<'py, PyDateTime>

Source§

fn get_tzinfo(&self) -> Option<Bound<'py, PyTzInfo>>

Returns the tzinfo (which may be None). Read more
Source§

fn get_tzinfo_bound(&self) -> Option<Bound<'py, PyTzInfo>>

👎Deprecated since 0.23.0: renamed to PyTzInfoAccess::get_tzinfo
Deprecated name for PyTzInfoAccess::get_tzinfo.
Source§

impl<'py> PyTzInfoAccess<'py> for Bound<'py, PyTime>

Source§

fn get_tzinfo(&self) -> Option<Bound<'py, PyTzInfo>>

Returns the tzinfo (which may be None). Read more
Source§

fn get_tzinfo_bound(&self) -> Option<Bound<'py, PyTzInfo>>

👎Deprecated since 0.23.0: renamed to PyTzInfoAccess::get_tzinfo
Deprecated name for PyTzInfoAccess::get_tzinfo.
Source§

impl<'py> PyWeakrefMethods<'py> for Bound<'py, PyWeakref>

Source§

fn upgrade(&self) -> Option<Bound<'py, PyAny>>

Upgrade the weakref to a Bound PyAny reference to the target object if possible. Read more
Source§

fn upgrade_as<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeCheck,

Upgrade the weakref to a direct Bound object reference. Read more
Source§

unsafe fn upgrade_as_unchecked<T>(&self) -> Option<Bound<'py, T>>

Upgrade the weakref to a direct Bound object reference unchecked. The type of the recovered object is not checked before downcasting, this could lead to unexpected behavior. Use only when absolutely certain the type can be guaranteed. The weakref may still return None. Read more
Source§

fn upgrade_as_exact<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeInfo,

Upgrade the weakref to a exact direct Bound object reference. Read more
Source§

fn get_object(&self) -> Bound<'py, PyAny>

👎Deprecated since 0.23.0: Use upgrade instead
Retrieve to a Bound object pointed to by the weakref. Read more
Source§

impl<'py> PyWeakrefMethods<'py> for Bound<'py, PyWeakrefProxy>

Source§

fn upgrade(&self) -> Option<Bound<'py, PyAny>>

Upgrade the weakref to a Bound PyAny reference to the target object if possible. Read more
Source§

fn upgrade_as<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeCheck,

Upgrade the weakref to a direct Bound object reference. Read more
Source§

unsafe fn upgrade_as_unchecked<T>(&self) -> Option<Bound<'py, T>>

Upgrade the weakref to a direct Bound object reference unchecked. The type of the recovered object is not checked before downcasting, this could lead to unexpected behavior. Use only when absolutely certain the type can be guaranteed. The weakref may still return None. Read more
Source§

fn upgrade_as_exact<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeInfo,

Upgrade the weakref to a exact direct Bound object reference. Read more
Source§

fn get_object(&self) -> Bound<'py, PyAny>

👎Deprecated since 0.23.0: Use upgrade instead
Retrieve to a Bound object pointed to by the weakref. Read more
Source§

impl<'py> PyWeakrefMethods<'py> for Bound<'py, PyWeakrefReference>

Source§

fn upgrade(&self) -> Option<Bound<'py, PyAny>>

Upgrade the weakref to a Bound PyAny reference to the target object if possible. Read more
Source§

fn upgrade_as<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeCheck,

Upgrade the weakref to a direct Bound object reference. Read more
Source§

unsafe fn upgrade_as_unchecked<T>(&self) -> Option<Bound<'py, T>>

Upgrade the weakref to a direct Bound object reference unchecked. The type of the recovered object is not checked before downcasting, this could lead to unexpected behavior. Use only when absolutely certain the type can be guaranteed. The weakref may still return None. Read more
Source§

fn upgrade_as_exact<T>(&self) -> PyResult<Option<Bound<'py, T>>>
where T: PyTypeInfo,

Upgrade the weakref to a exact direct Bound object reference. Read more
Source§

fn get_object(&self) -> Bound<'py, PyAny>

👎Deprecated since 0.23.0: Use upgrade instead
Retrieve to a Bound object pointed to by the weakref. Read more
Source§

impl<'py> Sub<&Bound<'py, PyComplex>> for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the - operation. Read more
Source§

impl<'py> Sub<Bound<'py, PyComplex>> for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the - operation. Read more
Source§

impl<'py> Sub for &Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the - operation. Read more
Source§

impl<'py> Sub for Bound<'py, PyComplex>

Source§

type Output = Bound<'py, PyComplex>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Bound<'py, PyComplex>) -> Bound<'py, PyComplex>

Performs the - operation. Read more
Source§

impl<T> ToPyObject for Bound<'_, T>

Source§

fn to_object(&self, py: Python<'_>) -> PyObject

👎Deprecated since 0.23.0: ToPyObject is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23/migration) for more information.

Converts &Bound instance -> PyObject, increasing the reference count.

Source§

impl<'py> TryFrom<&Bound<'py, PyAny>> for Bound<'py, PyByteArray>

Source§

fn try_from(value: &Bound<'py, PyAny>) -> Result<Self, Self::Error>

Creates a new Python bytearray object from another Python object that implements the buffer protocol.

Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

impl<'py> TryFrom<&Bound<'py, PyAny>> for Bound<'py, PyMemoryView>

Source§

fn try_from(value: &Bound<'py, PyAny>) -> Result<Self, Self::Error>

Creates a new Python memoryview object from another Python object that implements the buffer protocol.

Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

impl TryFrom<Bound<'_, PyString>> for PyBackedStr

Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn try_from(py_string: Bound<'_, PyString>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'py, T> Freeze for Bound<'py, T>

§

impl<'py, T> RefUnwindSafe for Bound<'py, T>
where T: RefUnwindSafe,

§

impl<'py, T> !Send for Bound<'py, T>

§

impl<'py, T> !Sync for Bound<'py, T>

§

impl<'py, T> Unpin for Bound<'py, T>
where T: Unpin,

§

impl<'py, T> UnwindSafe for Bound<'py, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

Source§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

fn type_input() -> TypeInfo

Extracts the type hint information for this type when it appears as an argument. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<I> IntoIterator for I
where I: Iterator,

Source§

type Item = <I as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = I

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> I

Creates an iterator from a value. Read more
Source§

impl<'py, T, I> IntoPyDict<'py> for I
where T: PyDictItem<'py>, I: IntoIterator<Item = T>,

Source§

fn into_py_dict(self, py: Python<'py>) -> Result<Bound<'py, PyDict>, PyErr>

Converts self into a PyDict object pointer. Whether pointer owned or borrowed depends on implementation.
Source§

fn into_py_dict_bound(self, py: Python<'py>) -> Bound<'py, PyDict>

👎Deprecated since 0.23.0: renamed to IntoPyDict::into_py_dict
Deprecated name for IntoPyDict::into_py_dict.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.