pub enum Unpacked {
Nil,
Bool(bool),
Int(i32),
Float(f64),
Sym(Symbol),
}Expand description
The tagged-union view of a Value, for exhaustive matching.
A Value hides its kind inside a bit pattern; Unpacked names it. Obtain one
with Value::unpack, and convert back with Value::from. This is the type
to match on when an interpreter dispatches on the kind of an operand.
§Examples
use value_lang::{Unpacked, Value};
let v = Value::float(1.5);
assert_eq!(v.unpack(), Unpacked::Float(1.5));
assert_eq!(Value::from(Unpacked::Int(3)), Value::int(3));Variants§
Nil
The unit value. See Value::nil.
Bool(bool)
A boolean. See Value::bool.
Int(i32)
A 32-bit signed integer. See Value::int.
Float(f64)
A double-precision float. See Value::float.
Sym(Symbol)
An interned symbol handle. See Value::sym.
Trait Implementations§
impl Copy for Unpacked
impl StructuralPartialEq for Unpacked
Auto Trait Implementations§
impl Freeze for Unpacked
impl RefUnwindSafe for Unpacked
impl Send for Unpacked
impl Sync for Unpacked
impl Unpin for Unpacked
impl UnsafeUnpin for Unpacked
impl UnwindSafe for Unpacked
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