[−][src]Trait rustpython_vm::pyobject::TryFromObject
Implemented by any type that can be created from a Python object.
Any type that implements TryFromObject
is automatically FromArgs
, and
so can be accepted as a argument to a built-in function.
Required methods
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
Attempt to convert a Python object to a value of this type.
Implementations on Foreign Types
impl TryFromObject for bool
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool>
[src]
impl TryFromObject for f32
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for f64
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for isize
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for i8
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for i16
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for i32
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for i64
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for usize
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for u8
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for u16
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for u32
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for u64
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl<T: TryFromObject> TryFromObject for Option<T>
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for Duration
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
Implementors
impl TryFromObject for ExceptionCtor
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for PyBytesLike
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for RangeIndex
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for SequenceIndex
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for IntoPyBool
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for PyByteInner
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for IntoPyFloat
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for PyCallable
[src]
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl TryFromObject for PyObjectRef
[src]
fn try_from_object(_vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl<A, B> TryFromObject for Either<A, B> where
A: TryFromObject,
B: TryFromObject,
[src]
A: TryFromObject,
B: TryFromObject,
This allows a builtin method to accept arguments that may be one of two
types, raising a TypeError
if it is neither.
Example
use rustpython_vm::VirtualMachine; use rustpython_vm::obj::{objstr::PyStringRef, objint::PyIntRef}; use rustpython_vm::pyobject::Either; fn do_something(arg: Either<PyIntRef, PyStringRef>, vm: &VirtualMachine) { match arg { Either::A(int)=> { // do something with int } Either::B(string) => { // do something with string } } }
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl<T> TryFromObject for PyIterable<T> where
T: TryFromObject,
[src]
T: TryFromObject,
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
[src]
impl<T> TryFromObject for PyRef<T> where
T: PyValue,
[src]
T: PyValue,