pub struct Scope<'a> {
pub row: Option<Row<'a>>,
pub args: Option<&'a BTreeMap<String, String>>,
pub globals: &'a dyn Globals,
pub missing_row_field: Option<&'a dyn Fn(&str)>,
}Expand description
The scopes a placeholder can resolve against.
Each caller brings the scopes it has: a <for> row brings Self::row,
a fragment instantiation brings Self::args, and a <for> inside a
fragment body meets both in turn.
Fields§
§row: Option<Row<'a>>The iteration in progress, absent outside a <for> body.
args: Option<&'a BTreeMap<String, String>>The arguments a fragment instance was built with, already folded over the declared defaults. Absent outside a fragment body.
globals: &'a dyn GlobalsWhere a global placeholder reads its value.
missing_row_field: Option<&'a dyn Fn(&str)>Told the name of a row field the iteration record does not have. Absent when the caller has nowhere to report it.
Implementations§
Source§impl<'a> Scope<'a>
impl<'a> Scope<'a>
Sourcepub fn new(globals: &'a dyn Globals) -> Self
pub fn new(globals: &'a dyn Globals) -> Self
A scope with globals alone: no iteration, no arguments, nothing to report to.
Sourcepub fn with_row(self, item: &'a ArrayItem, index: usize) -> Self
pub fn with_row(self, item: &'a ArrayItem, index: usize) -> Self
The same scope, iterating item at index.
Sourcepub fn with_args(self, args: &'a BTreeMap<String, String>) -> Self
pub fn with_args(self, args: &'a BTreeMap<String, String>) -> Self
The same scope, inside a fragment instantiated with args.
Sourcepub fn reporting_to(self, report: &'a dyn Fn(&str)) -> Self
pub fn reporting_to(self, report: &'a dyn Fn(&str)) -> Self
The same scope, reporting a row field the record does not have.