feat: split apart template mutations

This commit is contained in:
Jonathan Kelley committed 2022-11-08 19:39:37 -08:00
1 parent 203935834d
commit fc9fe6e560
21 files changed
+431 -222

No files matched your search

+73 -1
View File
@@ -1,9 +1,81 @@
use crate::arena::ElementId;
#[derive(Debug)]
pub struct Renderer<'a> {
mutations: Vec<Mutation<'a>>,
pub subtree: usize,
pub mutations: Vec<Mutation<'a>>,
pub template_mutations: Vec<Mutation<'a>>,
// mutations: Vec<Mutations<'a>>,
}
impl<'a> Renderer<'a> {
pub fn new(subtree: usize) -> Self {
Self {
subtree,
mutations: Vec::new(),
template_mutations: Vec::new(),
}
}
}
impl<'a> std::ops::Deref for Renderer<'a> {
type Target = Vec<Mutation<'a>>;
fn deref(&self) -> &Self::Target {
&self.mutations
}
}
impl std::ops::DerefMut for Renderer<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.mutations
}
}
// impl<'a> Renderer<'a> {
// pub fn new(subtree: usize) -> Self {
// Self {
// mutations: vec![Mutations {
// subtree,
// mutations: Vec::new(),
// }],
// }
// }
// }
// impl<'a> Renderer<'a> {
// pub fn push(&mut self, mutation: Mutation<'a>) {
// self.mutations.last_mut().unwrap().mutations.push(mutation)
// }
// pub fn extend(&mut self, mutations: impl IntoIterator<Item = Mutation<'a>>) {
// self.mutations
// .last_mut()
// .unwrap()
// .mutations
// .extend(mutations)
// }
// pub fn len(&self) -> usize {
// self.mutations.last().unwrap().mutations.len()
// }
// pub fn split_off(&mut self, idx: usize) -> Renderer<'a> {
// let mut mutations = self.mutations.split_off(idx);
// let subtree = mutations.pop().unwrap().subtree;
// Renderer { mutations }
// }
// }
// #[derive(Debug)]
// pub struct Mutations<'a> {
// subtree: usize,
// mutations: Vec<Mutation<'a>>,
// }
/*
each subtree has its own numbering scheme
*/
#[derive(Debug)]
pub enum Mutation<'a> {
SetAttribute {