pub struct ObjectRef<'a> { /* private fields */ }Expand description
A borrowed Python value, for inspecting results, arguments and inputs without copying.
Implementations§
Source§impl<'a> ObjectRef<'a>
impl<'a> ObjectRef<'a>
Sourcepub fn to_owned(&self) -> MontyObject
pub fn to_owned(&self) -> MontyObject
Copies into an owned value, preserving sharing within the value.
Sourcepub fn items(&self) -> Option<Vec<Self>>
pub fn items(&self) -> Option<Vec<Self>>
The items of a list, tuple, set, frozenset or namedtuple; None for
any other value.
Sourcepub fn pairs(&self) -> Option<Vec<(Self, Self)>>
pub fn pairs(&self) -> Option<Vec<(Self, Self)>>
The (key, value) pairs of a dict, or the attrs of a class instance,
class type object or module; None for any other value.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
The value as a float; an int converts as Python’s float() does,
with one too large for a float giving None where Python overflows.
Sourcepub fn as_decimal(&self) -> Option<&str>
pub fn as_decimal(&self) -> Option<&str>
The string form of a decimal.Decimal, as str(d) prints it.
Sourcepub fn as_complex(&self) -> Option<MontyComplex>
pub fn as_complex(&self) -> Option<MontyComplex>
The value as a complex; an int or float converts as Python’s
complex() does, with a zero imaginary part (see as_float
for an int too large to convert).
Trait Implementations§
impl<'a> Copy for ObjectRef<'a>
Source§impl PartialEq for ObjectRef<'_>
impl PartialEq for ObjectRef<'_>
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Structural equality as Python values: an int equals the same
BigInt, a namedtuple equals a tuple of its values, floats compare
bit-for-bit (so NaN round-trips equal), and a sub-object shared in
one arena equals its copies in another. Linear in the arenas: each
pair of nodes is compared once.
Source§impl PartialEq<MontyObject> for ObjectRef<'_>
impl PartialEq<MontyObject> for ObjectRef<'_>
Source§impl PartialEq<ObjectRef<'_>> for MontyObject
impl PartialEq<ObjectRef<'_>> for MontyObject
Source§impl PushValue for ObjectRef<'_>
impl PushValue for ObjectRef<'_>
Source§fn push_into(self, graph: &mut MontyGraph) -> NodeId
fn push_into(self, graph: &mut MontyGraph) -> NodeId
Copies the reachable nodes; a sub-object shared inside the value stays shared. Linear sweeps over the value’s index span, no recursion, so a deep value from an untrusted worker costs heap rather than native stack.
Source§impl TryFrom<ObjectRef<'_>> for i64
impl TryFrom<ObjectRef<'_>> for i64
Source§type Error = ConversionError
type Error = ConversionError
Source§impl TryFrom<ObjectRef<'_>> for f64
An int converts as Python’s float() does.
impl TryFrom<ObjectRef<'_>> for f64
An int converts as Python’s float() does.
Source§type Error = ConversionError
type Error = ConversionError
Source§impl TryFrom<ObjectRef<'_>> for String
impl TryFrom<ObjectRef<'_>> for String
Source§type Error = ConversionError
type Error = ConversionError
Source§impl TryFrom<ObjectRef<'_>> for bool
Only True/False convert; this is not Python truthiness (see ObjectRef::is_truthy).
impl TryFrom<ObjectRef<'_>> for bool
Only True/False convert; this is not Python truthiness (see ObjectRef::is_truthy).