pub struct PyIter<O = PyObjectRef>(/* private fields */)
where
O: Borrow<PyObject>;
Expand description
Iterator Protocol
Implementations§
Source§impl<O> PyIter<O>
impl<O> PyIter<O>
pub fn new(obj: O) -> Self
pub fn next(&self, vm: &VirtualMachine) -> PyResult<PyIterReturn>
pub fn iter<'a, 'b, U>( &'b self, vm: &'a VirtualMachine, ) -> PyResult<PyIterIter<'a, U, &'b PyObject>>
pub fn iter_without_hint<'a, 'b, U>( &'b self, vm: &'a VirtualMachine, ) -> PyResult<PyIterIter<'a, U, &'b PyObject>>
Source§impl PyIter<PyObjectRef>
impl PyIter<PyObjectRef>
Sourcepub fn into_iter<U>(
self,
vm: &VirtualMachine,
) -> PyResult<PyIterIter<'_, U, PyObjectRef>>
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>§
pub fn try_to_value<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<T>where
T: 'a + TryFromBorrowedObject<'a>,
pub fn try_to_ref<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>where
T: 'a + PyPayload,
pub fn try_value_with<T, F, R>(&self, f: F, vm: &VirtualMachine) -> PyResult<R>
pub fn try_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&[u8]) -> R, ) -> PyResult<R>
pub fn try_rw_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&mut [u8]) -> R, ) -> PyResult<R>
pub fn as_interned_str( &self, vm: &VirtualMachine, ) -> Option<&'static PyStrInterned>
pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<PyRef<PyWeak>>
pub fn get_weak_references(&self) -> Option<Vec<PyRef<PyWeak>>>
pub fn payload_is<T: PyObjectPayload>(&self) -> bool
Sourcepub unsafe fn payload_unchecked<T: PyObjectPayload>(&self) -> &T
pub unsafe fn payload_unchecked<T: PyObjectPayload>(&self) -> &T
pub fn payload<T: PyObjectPayload>(&self) -> Option<&T>
pub fn class(&self) -> &Py<PyType>
pub fn set_class(&self, typ: PyTypeRef, vm: &VirtualMachine)
pub fn payload_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&T>
pub fn dict(&self) -> Option<PyDictRef>
Sourcepub fn set_dict(&self, dict: PyDictRef) -> Result<(), PyDictRef>
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.
pub fn payload_if_subclass<T: PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&T>
pub fn downcast_ref<T: PyObjectPayload>(&self) -> Option<&Py<T>>
pub fn downcast_ref_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&Py<T>>
Sourcepub unsafe fn downcast_unchecked_ref<T: PyObjectPayload>(&self) -> &Py<T>
pub unsafe fn downcast_unchecked_ref<T: PyObjectPayload>(&self) -> &Py<T>
§Safety
T must be the exact payload type
pub fn strong_count(&self) -> usize
pub fn weak_count(&self) -> Option<usize>
pub fn as_raw(&self) -> *const PyObject
pub fn to_callable(&self) -> Option<PyCallable<'_>>
pub fn is_callable(&self) -> bool
Sourcepub fn call(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult
pub fn call(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult
PyObject_CallArg series
Sourcepub fn call_with_args(&self, args: FuncArgs, vm: &VirtualMachine) -> PyResult
pub fn call_with_args(&self, args: FuncArgs, vm: &VirtualMachine) -> PyResult
PyObject_Call
pub fn to_mapping(&self) -> PyMapping<'_>
pub fn to_number(&self) -> PyNumber<'_>
pub fn try_index_opt(&self, vm: &VirtualMachine) -> Option<PyResult<PyIntRef>>
pub fn try_index(&self, vm: &VirtualMachine) -> PyResult<PyIntRef>
pub fn try_int(&self, vm: &VirtualMachine) -> PyResult<PyIntRef>
pub fn try_float_opt( &self, vm: &VirtualMachine, ) -> Option<PyResult<PyRef<PyFloat>>>
pub fn try_float(&self, vm: &VirtualMachine) -> PyResult<PyRef<PyFloat>>
Sourcepub fn get_iter(&self, vm: &VirtualMachine) -> PyResult<PyIter>
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.
pub fn get_aiter(&self, vm: &VirtualMachine) -> PyResult
pub fn has_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine, ) -> PyResult<bool>
pub fn get_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine, ) -> PyResult
pub fn call_set_attr( &self, vm: &VirtualMachine, attr_name: &Py<PyStr>, attr_value: PySetterValue, ) -> PyResult<()>
pub fn set_attr<'a>( &self, attr_name: impl AsPyStr<'a>, attr_value: impl Into<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<()>
pub fn generic_setattr( &self, attr_name: &Py<PyStr>, value: PySetterValue, vm: &VirtualMachine, ) -> PyResult<()>
pub fn generic_getattr(&self, name: &Py<PyStr>, vm: &VirtualMachine) -> PyResult
Sourcepub fn generic_getattr_opt(
&self,
name_str: &Py<PyStr>,
dict: Option<PyDictRef>,
vm: &VirtualMachine,
) -> PyResult<Option<PyObjectRef>>
pub fn generic_getattr_opt( &self, name_str: &Py<PyStr>, dict: Option<PyDictRef>, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
CPython _PyObject_GenericGetAttrWithDict
pub fn del_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine, ) -> PyResult<()>
pub fn rich_compare_bool( &self, other: &Self, opid: PyComparisonOp, vm: &VirtualMachine, ) -> PyResult<bool>
pub fn repr(&self, vm: &VirtualMachine) -> PyResult<PyStrRef>
pub fn ascii(&self, vm: &VirtualMachine) -> PyResult<AsciiString>
pub fn str(&self, vm: &VirtualMachine) -> PyResult<PyStrRef>
Sourcepub fn is_subclass(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>
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.
Sourcepub fn is_instance(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>
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.
pub fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash>
pub fn obj_type(&self) -> PyObjectRef
pub fn type_check(&self, typ: &Py<PyType>) -> bool
pub fn length_opt(&self, vm: &VirtualMachine) -> Option<PyResult<usize>>
pub fn length(&self, vm: &VirtualMachine) -> PyResult<usize>
pub fn get_item<K: DictKey + ?Sized>( &self, needle: &K, vm: &VirtualMachine, ) -> PyResult
pub fn set_item<K: DictKey + ?Sized>( &self, needle: &K, value: PyObjectRef, vm: &VirtualMachine, ) -> PyResult<()>
pub fn del_item<K: DictKey + ?Sized>( &self, needle: &K, vm: &VirtualMachine, ) -> PyResult<()>
pub fn to_sequence(&self) -> PySequence<'_>
Trait Implementations§
Source§impl From<PyIter> for PyObjectRef
impl From<PyIter> for PyObjectRef
Source§fn from(value: PyIter<PyObjectRef>) -> PyObjectRef
fn from(value: PyIter<PyObjectRef>) -> PyObjectRef
Converts to this type from the input type.
Source§impl ToPyObject for PyIter<PyObjectRef>
impl ToPyObject for PyIter<PyObjectRef>
fn to_pyobject(self, _vm: &VirtualMachine) -> PyObjectRef
Source§impl<O: Borrow<PyObject>> Traverse for PyIter<O>
impl<O: Borrow<PyObject>> Traverse for PyIter<O>
Source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
impl
traverse()
with caution! Following those guideline so traverse doesn’t cause memory error!: Read moreSource§impl TryFromObject for PyIter<PyObjectRef>
impl TryFromObject for PyIter<PyObjectRef>
Source§fn try_from_object(
vm: &VirtualMachine,
iter_target: PyObjectRef,
) -> PyResult<Self>
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> Freeze for PyIter<O>where
O: Freeze,
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> AsObject for T
impl<T> AsObject for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromArgOptional for Twhere
T: TryFromObject,
impl<T> FromArgOptional for Twhere
T: TryFromObject,
Source§impl<T> FromArgs for Twhere
T: TryFromObject,
impl<T> FromArgs for Twhere
T: TryFromObject,
Source§fn arity() -> RangeInclusive<usize>
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>
fn from_args( vm: &VirtualMachine, args: &mut FuncArgs, ) -> Result<T, ArgumentError>
Extracts this item from the next argument(s).
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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