diff options
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r-- | tvix/eval/src/value/list.rs | 14 | ||||
-rw-r--r-- | tvix/eval/src/value/mod.rs | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs new file mode 100644 index 000000000000..08f56262e00c --- /dev/null +++ b/tvix/eval/src/value/list.rs @@ -0,0 +1,14 @@ +/// This module implements Nix lists. +use std::fmt::Display; + +use super::Value; + +#[derive(Clone, Debug, PartialEq)] +pub struct NixList(pub Vec<Value>); + +impl Display for NixList { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // TODO(tazjin): format lists properly + f.write_fmt(format_args!("<list({})>", self.0.len())) + } +} diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 56f8620d3a58..d00fc56e2a73 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -4,10 +4,12 @@ use std::fmt::Display; use std::rc::Rc; mod attrs; +mod list; mod string; use crate::errors::{Error, EvalResult}; pub use attrs::NixAttrs; +pub use list::NixList; pub use string::NixString; #[derive(Clone, Debug, PartialEq)] @@ -18,6 +20,7 @@ pub enum Value { Float(f64), String(NixString), Attrs(Rc<NixAttrs>), + List(NixList), } impl Value { @@ -37,6 +40,7 @@ impl Value { Value::Float(_) => "float", Value::String(_) => "string", Value::Attrs(_) => "set", + Value::List(_) => "list", } } @@ -71,6 +75,7 @@ impl Display for Value { Value::Float(num) => f.write_fmt(format_args!("{}", num)), Value::String(s) => s.fmt(f), Value::Attrs(attrs) => attrs.fmt(f), + Value::List(list) => list.fmt(f), } } } |