Add select

This commit is contained in:
JT
2021-10-02 17:55:05 +13:00
parent 7899745c4b
commit 6b76dd7cd7
6 changed files with 213 additions and 2 deletions

View File

@ -13,6 +13,24 @@ pub struct CellPath {
pub members: Vec<PathMember>,
}
impl CellPath {
pub fn into_string(&self) -> String {
let mut output = String::new();
for (idx, elem) in self.members.iter().enumerate() {
if idx > 0 {
output.push('.');
}
match elem {
PathMember::Int { val, .. } => output.push_str(&format!("{}", val)),
PathMember::String { val, .. } => output.push_str(val),
}
}
output
}
}
#[derive(Debug, Clone)]
pub struct FullCellPath {
pub head: Expression,

View File

@ -191,7 +191,7 @@ impl Value {
Value::Nothing { .. } => String::new(),
Value::Error { error } => format!("{:?}", error),
Value::Binary { val, .. } => format!("{:?}", val),
Value::CellPath { val, .. } => format!("{:?}", val),
Value::CellPath { val, .. } => val.into_string(),
}
}
@ -223,7 +223,7 @@ impl Value {
Value::Nothing { .. } => String::new(),
Value::Error { error } => format!("{:?}", error),
Value::Binary { val, .. } => format!("{:?}", val),
Value::CellPath { val, .. } => format!("{:?}", val),
Value::CellPath { .. } => self.into_string(),
}
}