clone EdnItem

This commit is contained in:
🪞👃🪞 2025-01-05 22:52:35 +01:00
parent 400fd9b6e9
commit 3dd8a7bc0d
8 changed files with 190 additions and 169 deletions

View file

@ -38,6 +38,18 @@ impl<T: PartialEq> PartialEq for EdnItem<T> {
}
}
}
impl EdnItem<&str> {
pub fn clone (&self) -> EdnItem<String> {
use EdnItem::*;
match self {
Nil => Nil,
Num(u) => Num(*u),
Sym(u) => Sym(u.to_string()),
Key(u) => Key(u.to_string()),
Exp(e) => Exp(e.iter().map(|i|i.clone()).collect()),
}
}
}
impl<T: AsRef<str> + PartialEq + Default + Clone + std::fmt::Debug> EdnItem<T> {
pub fn to_ref (&self) -> EdnItem<&str> {
match self {