pub enum Value {
Int(i64),
Float(f64),
Bool(bool),
Text(String),
Char(char),
Nothing,
}Expand description
Dynamic value type for heterogeneous collections.
Value enables tuples and other heterogeneous data structures in Logos.
It supports basic arithmetic between compatible types and provides
runtime type coercion where sensible.
§Variants
Int(i64)- Integer valuesFloat(f64)- Floating-point valuesBool(bool)- Boolean valuesText(String)- String valuesChar(char)- Single character valuesNothing- Unit/null value
§Arithmetic
Arithmetic operations are supported between numeric types:
Int op Int→IntFloat op Float→FloatInt op FloatorFloat op Int→Float(promotion)Text + Text→Text(concatenation)
§Panics
Arithmetic on incompatible variants panics at runtime.
§Examples
use logicaffeine_data::Value;
let a = Value::Int(10);
let b = Value::Int(3);
assert_eq!(a + b, Value::Int(13));
let x = Value::Float(2.5);
let y = Value::Int(2);
assert_eq!(x * y, Value::Float(5.0));Variants§
Int(i64)
Integer values.
Float(f64)
Floating-point values.
Bool(bool)
Boolean values.
Text(String)
String values.
Char(char)
Single character values.
Nothing
Unit/null value.
Trait Implementations§
impl StructuralPartialEq for Value
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