@ -785,6 +785,80 @@ impl<'a> DustRenderer<'a> {
new_context_element . map ( | ctx | new_stack . push ( ctx ) ) ;
Some ( new_stack )
}
fn new_breadcrumbs_section < ' b > (
breadcrumbs : & ' b Vec < & ' b dyn ContextElement > ,
index_context : Option < & ' b dyn ContextElement > ,
injected_context : Option < & ' b dyn ContextElement > ,
explicit_context : & Option < Path < ' b > > ,
new_context_element : Option < & ' b dyn ContextElement > ,
) -> Option < Vec < & ' b dyn ContextElement > > {
// If none of the additional contexts are present, return None
// to signal that the original breadcrumbs should be used
// rather than incurring a copy here.
match (
index_context ,
injected_context ,
explicit_context ,
new_context_element ,
) {
( None , None , None , None ) = > return None ,
_ = > ( ) ,
}
let mut new_stack = match explicit_context {
Some ( _ ) = > Vec ::with_capacity ( 4 ) ,
None = > breadcrumbs . clone ( ) ,
} ;
explicit_context . as_ref ( ) . map ( | path | {
walk_path ( breadcrumbs , & path . keys ) . map ( | val | {
if val . is_truthy ( ) {
new_stack . push ( val )
}
} ) ;
} ) ;
injected_context . map ( | ctx | new_stack . push ( ctx ) ) ;
new_context_element . map ( | ctx | new_stack . push ( ctx ) ) ;
index_context . map ( | ctx | new_stack . push ( ctx ) ) ;
Some ( new_stack )
}
fn new_breadcrumbs_partial < ' b > (
breadcrumbs : & ' b Vec < & ' b dyn ContextElement > ,
explicit_context_breadcrumbs : & ' b Vec < & ' b dyn ContextElement > ,
injected_context : Option < & ' b dyn ContextElement > ,
explicit_context : & Option < Path < ' b > > ,
) -> Option < Vec < & ' b dyn ContextElement > > {
// If none of the additional contexts are present, return None
// to signal that the original breadcrumbs should be used
// rather than incurring a copy here.
match ( injected_context , explicit_context ) {
( None , None ) = > return None ,
_ = > ( ) ,
} ;
let mut new_stack = match explicit_context {
Some ( _ ) = > Vec ::with_capacity ( 3 ) ,
None = > breadcrumbs . clone ( ) ,
} ;
injected_context . map ( | ctx | {
// Special case: when there is no explicit context, the
// injected context gets inserted 1 spot behind the
// current context. Otherwise, the injected context gets
// added after the current context but before the explicit
// context.
match explicit_context {
None = > new_stack . insert ( std ::cmp ::max ( new_stack . len ( ) - 1 , 0 ) , ctx ) ,
_ = > new_stack . push ( ctx ) ,
}
} ) ;
explicit_context . as_ref ( ) . map ( | path | {
walk_path ( explicit_context_breadcrumbs , & path . keys ) . map ( | val | {
if val . is_truthy ( ) {
new_stack . push ( val )
}
} ) ;
} ) ;
Some ( new_stack )
}
}
struct BlockContext < ' a > {