Struct PyNumber

Source
pub struct PyNumber<'a>(/* private fields */);

Implementations§

Source§

impl<'a> PyNumber<'a>

Source

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

Source§

impl PyNumber<'_>

Methods from Deref<Target = PyObject>§

Source

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

Source

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

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 get_aiter(&self, vm: &VirtualMachine) -> PyResult

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 obj_type(&self) -> PyObjectRef

Source

pub fn type_check(&self, typ: &Py<PyType>) -> bool

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) -> PySequence<'_>

Trait Implementations§

Source§

impl<'a> Clone for PyNumber<'a>

Source§

fn clone(&self) -> PyNumber<'a>

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<'a> Deref for PyNumber<'a>

Source§

type Target = PyObject

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Traverse for PyNumber<'_>

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<'a> Copy for PyNumber<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for PyNumber<'a>

§

impl<'a> !RefUnwindSafe for PyNumber<'a>

§

impl<'a> !Send for PyNumber<'a>

§

impl<'a> !Sync for PyNumber<'a>

§

impl<'a> Unpin for PyNumber<'a>

§

impl<'a> !UnwindSafe for PyNumber<'a>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn exact_from(value: T) -> U

Source§

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

Source§

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, 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<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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

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

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

Source§

fn vzip(self) -> V

Source§

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

Source§

fn wrapping_into(self) -> U

Source§

impl<T> PyThreadingConstraint for T

Morty Proxy This is a proxified and sanitized view of the page, visit original site.