use crate::{Hashable, Level};
use alloc::string::{String, ToString};
pub trait Frontier<H> {
fn append(&mut self, value: H) -> bool;
fn root(&self) -> H;
}
impl Hashable for String {
fn empty_leaf() -> Self {
"_".to_string()
}
fn combine(_: Level, a: &Self, b: &Self) -> Self {
a.to_string() + b
}
}
impl<H: Hashable> Hashable for Option<H> {
fn empty_leaf() -> Self {
Some(H::empty_leaf())
}
fn combine(l: Level, a: &Self, b: &Self) -> Self {
match (a, b) {
(Some(a), Some(b)) => Some(H::combine(l, a, b)),
_ => None,
}
}
}