This commit is contained in:
soup 2024-05-19 03:16:51 -04:00
parent af3fa30986
commit 323a38db3a
No known key found for this signature in database

View file

@ -295,7 +295,37 @@ where
} }
} }
mod build {} impl<T> Value for Vec<T>
where
T: Value,
{
fn print(&self, w: &mut String) {
for v in self.iter() {
v.print(w)
}
}
fn lookup(&self, name: &str) -> Option<&dyn Value> {
let idx: usize = name.parse().ok()?;
self.get(idx).map(|v| v as &dyn Value)
}
fn has(&self) -> Option<&dyn Value> {
if self.is_empty() {
None
} else {
Some(self)
}
}
fn if_(&self) -> bool {
self.is_empty()
}
fn for_(&self, index: usize) -> Option<&dyn Value> {
self.get(index).map(|v| v as &dyn Value)
}
}
pub struct Newt { pub struct Newt {
ast: Ast, ast: Ast,