pub enum Value {
Show 21 variants
Int(i32),
Float(f64),
Bool(bool),
None,
String(String),
List(Rc<RefCell<ListValue>>),
Dict(Rc<RefCell<HashMap<DictKey, Value>>>),
Tuple(Rc<Vec<Value>>),
Slice {
start: Option<i32>,
stop: Option<i32>,
step: Option<i32>,
},
Iterator(Rc<RefCell<IteratorState>>),
Function(Function),
Coroutine(Function, Vec<Value>),
Generator(Rc<RefCell<GeneratorState>>),
AsyncSleep(f64),
Exception(ExceptionValue),
Module(Rc<RefCell<Module>>),
NativeFunction(fn(Vec<Value>) -> Result<Value, Value>),
BoundMethod(Box<Value>, String),
Regex(Rc<Regex>),
Match(Rc<MatchObject>),
Type(TypeObject),
}Expand description
Value type for QuickPython runtime
Variants§
Int(i32)
Float(f64)
Bool(bool)
None
String(String)
List(Rc<RefCell<ListValue>>)
Dict(Rc<RefCell<HashMap<DictKey, Value>>>)
Tuple(Rc<Vec<Value>>)
Slice
Iterator(Rc<RefCell<IteratorState>>)
Function(Function)
Coroutine(Function, Vec<Value>)
Generator(Rc<RefCell<GeneratorState>>)
AsyncSleep(f64)
Exception(ExceptionValue)
Module(Rc<RefCell<Module>>)
NativeFunction(fn(Vec<Value>) -> Result<Value, Value>)
BoundMethod(Box<Value>, String)
Regex(Rc<Regex>)
Match(Rc<MatchObject>)
Type(TypeObject)
Implementations§
Source§impl Value
impl Value
pub fn as_int(&self) -> Option<i32>
pub fn as_float(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_string(&self) -> Option<&str>
pub fn as_list(&self) -> Option<Rc<RefCell<ListValue>>>
pub fn as_dict(&self) -> Option<Rc<RefCell<HashMap<DictKey, Value>>>>
Sourcepub fn error(exception_type: ExceptionType, message: impl Into<String>) -> Value
pub fn error(exception_type: ExceptionType, message: impl Into<String>) -> Value
Create an exception value
Sourcepub fn is_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Check if value is an exception
Sourcepub fn as_exception(&self) -> Option<&ExceptionValue>
pub fn as_exception(&self) -> Option<&ExceptionValue>
Get exception value
pub fn is_truthy(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Value
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl !UnwindSafe for Value
Blanket Implementations§
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> 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