rlox/vm/src/value.rs

22 lines
420 B
Rust
Raw Normal View History

use std::fmt::Display;
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Nil,
Number(f64),
}
impl Default for Value {
fn default() -> Self {
Value::Nil
}
}
impl Display for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Value::Nil => write!(f, "nil"),
Value::Number(num) => write!(f, "{num}"),
}
}
}