factor out simple templates into a separate SimpleTemplateDir
there's no need to bloat TreehouseDir with that logic
This commit is contained in:
parent
b792688776
commit
550c062327
7 changed files with 211 additions and 156 deletions
|
|
@ -2,6 +2,8 @@ use std::fmt;
|
|||
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::vfs::ToDynDir;
|
||||
|
||||
use super::{entries, Dir, DynDir, Entries, Query, VPath, VPathBuf};
|
||||
|
||||
pub struct Overlay {
|
||||
|
|
@ -38,3 +40,18 @@ impl fmt::Debug for Overlay {
|
|||
write!(f, "Overlay({:?}, {:?})", self.base, self.overlay)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layered_dir(layers: &[DynDir]) -> DynDir {
|
||||
match layers {
|
||||
[] => ().to_dyn(),
|
||||
[dir] => dir.clone(),
|
||||
[left, right] => Overlay::new(left.clone(), right.clone()).to_dyn(),
|
||||
[left, right, rest @ ..] => {
|
||||
let mut overlay = Overlay::new(left.clone(), right.clone());
|
||||
for dir in rest {
|
||||
overlay = Overlay::new(overlay.to_dyn(), dir.clone());
|
||||
}
|
||||
overlay.to_dyn()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue