wip: preparing to run groovebox from edn

This commit is contained in:
🪞👃🪞 2025-01-05 17:10:57 +01:00
parent ce4574ed78
commit a6efde40f8
5 changed files with 43 additions and 28 deletions

View file

@ -41,14 +41,20 @@ impl<T: PartialEq> PartialEq for EdnItem<T> {
impl<T: AsRef<str> + PartialEq + Default + Clone + std::fmt::Debug> EdnItem<T> {
pub fn to_ref (&self) -> EdnItem<&str> {
match self {
Self::Nil => EdnItem::Nil,
Self::Num(x) => EdnItem::Num(*x),
Self::Key(x) => EdnItem::Key(x.as_ref()),
_ => todo!()
Self::Sym(x) => EdnItem::Sym(x.as_ref()),
Self::Exp(x) => EdnItem::Exp(x.iter().map(|x|x.to_ref()).collect::<Vec<_>>()),
}
}
pub fn to_str (&self) -> &str {
match self {
Self::Nil => "",
Self::Num(_) => "",
Self::Key(x) => x.as_ref(),
_ => todo!()
Self::Sym(x) => x.as_ref(),
Self::Exp(_) => "",
}
}
pub fn symbols <'a> (&'a self) -> EdnIterator<'a, T> {