Port majority of layouting logic

This commit is contained in:
Joscha 2022-07-19 18:09:30 +02:00
parent e7cd0568e9
commit 47aa99bb26
4 changed files with 222 additions and 99 deletions

View file

@ -1,6 +1,7 @@
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;
use std::vec;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
@ -31,6 +32,10 @@ impl<I> Path<I> {
&self.0
}
pub fn push(&mut self, segment: I) {
self.0.push(segment)
}
pub fn first(&self) -> &I {
self.0.first().expect("path is not empty")
}
@ -48,6 +53,15 @@ impl<I> Path<I> {
}
}
impl<I> IntoIterator for Path<I> {
type Item = I;
type IntoIter = vec::IntoIter<I>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
pub struct Tree<M: Msg> {
root: M::Id,
msgs: HashMap<M::Id, M>,