#[repr(transparent)]
pub struct PyIter<O = PyObjectRef>(_) where O: Borrow<PyObject>;
Expand description

Iterator Protocol

Implementations§

source§

impl PyIter<PyObjectRef>

source

pub fn check(obj: &PyObject) -> bool

source§

impl<O> PyIter<O>where O: Borrow<PyObject>,

source

pub fn new(obj: O) -> Self

source

pub fn next(&self, vm: &VirtualMachine) -> PyResult<PyIterReturn>

source

pub fn iter<'a, 'b, U>( &'b self, vm: &'a VirtualMachine ) -> PyResult<PyIterIter<'a, U, &'b PyObject>>

source

pub fn iter_without_hint<'a, 'b, U>( &'b self, vm: &'a VirtualMachine ) -> PyResult<PyIterIter<'a, U, &'b PyObject>>

source§

impl PyIter<PyObjectRef>

source

pub fn into_iter<U>( self, vm: &VirtualMachine ) -> PyResult<PyIterIter<'_, U, PyObjectRef>>

Returns an iterator over this sequence of objects.

Methods from Deref<Target = PyObject>§

source

pub fn try_to_value<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<T>where T: TryFromBorrowedObject<'a> + 'a,

source

pub fn try_to_ref<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>where T: PyPayload + 'a,

source

pub fn try_value_with<T, F, R>(&self, f: F, vm: &VirtualMachine) -> PyResult<R>where T: PyPayload, F: Fn(&T) -> PyResult<R>,

source

pub fn try_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&[u8]) -> R ) -> PyResult<R>

source

pub fn try_rw_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&mut [u8]) -> R ) -> PyResult<R>

source

pub fn as_interned_str( &self, vm: &VirtualMachine ) -> Option<&'static PyStrInterned>

source

pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine ) -> PyResult<PyRef<PyWeak>>

source

pub fn get_weak_references(&self) -> Option<Vec<PyRef<PyWeak>>>

source

pub fn payload_is<T: PyObjectPayload>(&self) -> bool

source

pub unsafe fn payload_unchecked<T: PyObjectPayload>(&self) -> &T

Force to return payload as T.

Safety

The actual payload type must be T.

source

pub fn payload<T: PyObjectPayload>(&self) -> Option<&T>

source

pub fn class(&self) -> &Py<PyType>

source

pub fn set_class(&self, typ: PyTypeRef, vm: &VirtualMachine)

source

pub fn payload_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine ) -> Option<&T>

source

pub fn dict(&self) -> Option<PyDictRef>

source

pub fn set_dict(&self, dict: PyDictRef) -> Result<(), PyDictRef>

Set the dict field. Returns Err(dict) if this object does not have a dict field in the first place.

source

pub fn payload_if_subclass<T: PyPayload>( &self, vm: &VirtualMachine ) -> Option<&T>

source

pub fn downcast_ref<T: PyObjectPayload>(&self) -> Option<&Py<T>>

source

pub fn downcast_ref_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine ) -> Option<&Py<T>>

source

pub unsafe fn downcast_unchecked_ref<T: PyObjectPayload>(&self) -> &Py<T>

Safety

T must be the exact payload type

source

pub fn strong_count(&self) -> usize

source

pub fn weak_count(&self) -> Option<usize>

source

pub fn as_raw(&self) -> *const PyObject

source

pub fn to_callable(&self) -> Option<PyCallable<'_>>

source

pub fn is_callable(&self) -> bool

source

pub fn call(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult

PyObject_CallArg series

source

pub fn call_with_args(&self, args: FuncArgs, vm: &VirtualMachine) -> PyResult

PyObject_Call

source

pub fn to_mapping(&self) -> PyMapping<'_>

source

pub fn to_number(&self) -> PyNumber<'_>

source

pub fn try_index_opt(&self, vm: &VirtualMachine) -> Option<PyResult<PyIntRef>>

source

pub fn try_index(&self, vm: &VirtualMachine) -> PyResult<PyIntRef>

source

pub fn try_int(&self, vm: &VirtualMachine) -> PyResult<PyIntRef>

source

pub fn try_float_opt( &self, vm: &VirtualMachine ) -> Option<PyResult<PyRef<PyFloat>>>

source

pub fn try_float(&self, vm: &VirtualMachine) -> PyResult<PyRef<PyFloat>>

source

pub fn get_iter(&self, vm: &VirtualMachine) -> PyResult<PyIter>

Takes an object and returns an iterator for it. This is typically a new iterator but if the argument is an iterator, this returns itself.

source

pub fn has_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine ) -> PyResult<bool>

source

pub fn get_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine ) -> PyResult

source

pub fn call_set_attr( &self, vm: &VirtualMachine, attr_name: &Py<PyStr>, attr_value: PySetterValue ) -> PyResult<()>

source

pub fn set_attr<'a>( &self, attr_name: impl AsPyStr<'a>, attr_value: impl Into<PyObjectRef>, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn generic_setattr( &self, attr_name: &Py<PyStr>, value: PySetterValue, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn generic_getattr(&self, name: &Py<PyStr>, vm: &VirtualMachine) -> PyResult

source

pub fn generic_getattr_opt( &self, name_str: &Py<PyStr>, dict: Option<PyDictRef>, vm: &VirtualMachine ) -> PyResult<Option<PyObjectRef>>

CPython _PyObject_GenericGetAttrWithDict

source

pub fn del_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn rich_compare_bool( &self, other: &Self, opid: PyComparisonOp, vm: &VirtualMachine ) -> PyResult<bool>

source

pub fn repr(&self, vm: &VirtualMachine) -> PyResult<PyStrRef>

source

pub fn ascii(&self, vm: &VirtualMachine) -> PyResult<AsciiString>

source

pub fn str(&self, vm: &VirtualMachine) -> PyResult<PyStrRef>

source

pub fn is_subclass(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>

Determines if self is a subclass of cls, either directly, indirectly or virtually via the subclasscheck magic method.

source

pub fn is_instance(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>

Determines if self is an instance of cls, either directly, indirectly or virtually via the instancecheck magic method.

source

pub fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash>

source

pub fn length_opt(&self, vm: &VirtualMachine) -> Option<PyResult<usize>>

source

pub fn length(&self, vm: &VirtualMachine) -> PyResult<usize>

source

pub fn get_item<K: DictKey + ?Sized>( &self, needle: &K, vm: &VirtualMachine ) -> PyResult

source

pub fn set_item<K: DictKey + ?Sized>( &self, needle: &K, value: PyObjectRef, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn del_item<K: DictKey + ?Sized>( &self, needle: &K, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn to_sequence(&self, vm: &VirtualMachine) -> PySequence<'_>

Trait Implementations§

source§

impl<O> AsRef<PyObject> for PyIter<O>where O: Borrow<PyObject>,

source§

fn as_ref(&self) -> &PyObject

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

impl<O> Borrow<PyObject> for PyIter<O>where O: Borrow<PyObject>,

source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
source§

impl<O> Clone for PyIter<O>where O: Borrow<PyObject> + Clone,

source§

fn clone(&self) -> PyIter<O>

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<O> Debug for PyIter<O>where O: Borrow<PyObject> + Debug,

source§

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

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

impl<O> Deref for PyIter<O>where O: Borrow<PyObject>,

§

type Target = PyObject

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl From<PyIter<PyObjectRef>> for PyObjectRef

source§

fn from(value: PyIter<PyObjectRef>) -> PyObjectRef

Converts to this type from the input type.
source§

impl ToPyObject for PyIter<PyObjectRef>

source§

impl<O: Borrow<PyObject>> Traverse for PyIter<O>

source§

fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)

impl traverse() with caution! Following those guideline so traverse doesn’t cause memory error!: Read more
source§

impl TryFromObject for PyIter<PyObjectRef>

source§

fn try_from_object( vm: &VirtualMachine, iter_target: PyObjectRef ) -> PyResult<Self>

Attempt to convert a Python object to a value of this type.

Auto Trait Implementations§

§

impl<O> RefUnwindSafe for PyIter<O>where O: RefUnwindSafe,

§

impl<O> Send for PyIter<O>where O: Send,

§

impl<O> Sync for PyIter<O>where O: Sync,

§

impl<O> Unpin for PyIter<O>where O: Unpin,

§

impl<O> UnwindSafe for PyIter<O>where O: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsObject for Twhere T: Borrow<PyObject>,

source§

fn as_object(&self) -> &PyObject

source§

fn get_id(&self) -> usize

source§

fn is<T>(&self, other: &T) -> boolwhere T: AsObject,

source§

fn class(&self) -> &Py<PyType>

source§

fn get_class_attr( &self, attr_name: &'static PyStrInterned ) -> Option<PyObjectRef>

source§

fn fast_isinstance(&self, cls: &Py<PyType>) -> bool

Determines if obj actually an instance of cls, this doesn’t call instancecheck, so only use this if cls is known to have not overridden the base instancecheck magic method.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> ExactFrom<T> for Uwhere U: TryFrom<T>,

§

fn exact_from(value: T) -> U

§

impl<T, U> ExactInto<U> for Twhere U: ExactFrom<T>,

§

fn exact_into(self) -> U

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromArgOptional for Twhere T: TryFromObject,

§

type Inner = T

source§

fn from_inner(x: T) -> T

source§

impl<T> FromArgs for Twhere T: TryFromObject,

source§

fn arity() -> RangeInclusive<usize>

The range of positional arguments permitted by the function signature. Read more
source§

fn from_args( vm: &VirtualMachine, args: &mut FuncArgs ) -> Result<T, ArgumentError>

Extracts this item from the next argument(s).
source§

impl<T, U> Into<U> for Twhere 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> IntoObject for Twhere T: Into<PyObjectRef>,

§

impl<T, U> OverflowingInto<U> for Twhere U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

impl<T, U> RoundingInto<U> for Twhere U: RoundingFrom<T>,

§

fn rounding_into(self, rm: RoundingMode) -> U

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T, U> SaturatingInto<U> for Twhere U: SaturatingFrom<T>,

§

fn saturating_into(self) -> U

§

impl<T> ToDebugString for Twhere T: Debug,

§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToPyResult for Twhere T: ToPyObject,

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> WrappingInto<U> for Twhere U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U

source§

impl<T> PyThreadingConstraint for T