mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
22 lines
420 B
Rust
22 lines
420 B
Rust
|
|
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}"),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|