Finished converting back to Vec.
This commit is contained in:
parent
b0efe50410
commit
00699b84ba
@ -242,12 +242,12 @@ impl<'a> DustRenderer<'a> {
|
|||||||
|
|
||||||
fn new_breadcrumbs_partial<'b>(
|
fn new_breadcrumbs_partial<'b>(
|
||||||
&'b self,
|
&'b self,
|
||||||
maybe_breadcrumbs: &'b Vec<BreadcrumbTreeElement<'b>>,
|
breadcrumbs: &'b Vec<BreadcrumbTreeElement<'b>>,
|
||||||
explicit_context_maybe_breadcrumbs: &'a Vec<BreadcrumbTreeElement<'a>>,
|
explicit_context_breadcrumbs: &'a Vec<BreadcrumbTreeElement<'a>>,
|
||||||
injected_context: Option<&'b dyn IntoContextElement>,
|
injected_context: Option<&'b dyn IntoContextElement>,
|
||||||
explicit_context: &Option<Path<'b>>,
|
explicit_context: &Option<Path<'b>>,
|
||||||
) {
|
) -> Option<Vec<BreadcrumbTreeElement<'b>>> {
|
||||||
/*
|
|
||||||
// If none of the additional contexts are present, return None
|
// If none of the additional contexts are present, return None
|
||||||
// to signal that the original breadcrumbs should be used
|
// to signal that the original breadcrumbs should be used
|
||||||
// rather than incurring a copy here.
|
// rather than incurring a copy here.
|
||||||
@ -258,11 +258,10 @@ impl<'a> DustRenderer<'a> {
|
|||||||
|
|
||||||
// If there is an explicit context, then drop all the current
|
// If there is an explicit context, then drop all the current
|
||||||
// context
|
// context
|
||||||
let mut parent = match explicit_context {
|
let mut new_stack = match explicit_context {
|
||||||
Some(_) => None,
|
Some(_) => Vec::with_capacity(3),
|
||||||
None => maybe_breadcrumbs,
|
None => breadcrumbs.clone(),
|
||||||
};
|
};
|
||||||
let mut new_nodes: Vec<BreadcrumbTreeElement> = Vec::new();
|
|
||||||
|
|
||||||
injected_context.map(|ctx| {
|
injected_context.map(|ctx| {
|
||||||
// Special case: when there is no explicit context, the
|
// Special case: when there is no explicit context, the
|
||||||
@ -271,32 +270,27 @@ impl<'a> DustRenderer<'a> {
|
|||||||
// added after the current context but before the explicit
|
// added after the current context but before the explicit
|
||||||
// context.
|
// context.
|
||||||
match explicit_context {
|
match explicit_context {
|
||||||
None => {
|
None => new_stack.insert(Self::get_index_of_first_non_pseudo_element(&new_stack).unwrap_or(0), BreadcrumbTreeElement::from_borrowed(ctx)),
|
||||||
let (new_parent, passed_nodes) =
|
_ => new_stack.push(BreadcrumbTreeElement::from_borrowed(ctx))
|
||||||
Self::split_tree_at_predicate(parent, |b| b.get_ice().is_pseudo_element());
|
|
||||||
parent = new_parent;
|
|
||||||
new_nodes.extend(passed_nodes.iter().map(|b| b.get_element().clone()));
|
|
||||||
}
|
|
||||||
_ => new_nodes.push(BreadcrumbTreeElement::from_borrowed(ctx)),
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
explicit_context.as_ref().map(|path| {
|
explicit_context.as_ref().map(|path| {
|
||||||
// TODO: should resolving the value here use
|
// TODO: should resolving the value here use
|
||||||
// explicit_context_maybe_breadcrumbs or
|
// explicit_context_maybe_breadcrumbs or
|
||||||
// maybe_breadcrumbs?
|
// maybe_breadcrumbs?
|
||||||
walk_path(explicit_context_maybe_breadcrumbs, &path.keys)
|
walk_path(explicit_context_breadcrumbs, &path.keys)
|
||||||
.map(|ice| ice.into_context_element(self, maybe_breadcrumbs))
|
.map(|ice| ice.into_context_element(self, breadcrumbs))
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|val| {
|
.map(|val| {
|
||||||
if val.get_context_element_reference().is_truthy() {
|
if val.get_context_element_reference().is_truthy() {
|
||||||
new_nodes.push(std::convert::From::from(val));
|
new_stack.push(std::convert::From::from(val));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Some((parent, new_nodes))*/
|
Some(new_stack)
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn preprocess_filters(filters: &Vec<Filter>) -> Vec<Filter> {
|
fn preprocess_filters(filters: &Vec<Filter>) -> Vec<Filter> {
|
||||||
@ -313,6 +307,13 @@ impl<'a> DustRenderer<'a> {
|
|||||||
}
|
}
|
||||||
final_filters
|
final_filters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_index_of_first_non_pseudo_element<'b>(breadcrumbs: &'b Vec<BreadcrumbTreeElement<'b>>) -> Option<usize>
|
||||||
|
{
|
||||||
|
breadcrumbs
|
||||||
|
.iter()
|
||||||
|
.rposition(|b| std::borrow::Borrow::<dyn IntoContextElement + 'b>::borrow(b).is_pseudo_element())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BlockContext<'a> {
|
struct BlockContext<'a> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user