Files
ngr/src/eval/value.rs
Adam Wick 1fbfd0c2d2 📜 Add better documentation across the compiler. (#3)
These changes pay particular attention to API endpoints, to try to
ensure that any rustdocs generated are detailed and sensible. A good
next step, eventually, might be to include doctest examples, as well.
For the moment, it's not clear that they would provide a lot of value,
though.

In addition, this does a couple refactors to simplify the code base in
ways that make things clearer or, at least, briefer.
2023-05-13 15:00:08 -05:00

26 lines
609 B
Rust

use std::fmt::Display;
/// Values in the interpreter.
///
/// Yes, this is yet another definition of a structure called `Value`, which
/// are almost entirely identical. However, it's nice to have them separated
/// by type so that we don't mix them up.
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
I64(i64),
}
impl Display for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Value::I64(x) => write!(f, "{}i64", x),
}
}
}
impl From<i64> for Value {
fn from(value: i64) -> Self {
Value::I64(value)
}
}