Encapsulate structures.

This commit is contained in:
Stephen Chung
2020-12-14 23:05:13 +08:00
parent 5ea6efe6fd
commit 17310ef576
4 changed files with 18 additions and 26 deletions

View File

@@ -532,7 +532,7 @@ pub struct Limits {
#[derive(Debug)]
pub struct EvalContext<'e, 'x, 'px: 'x, 'a, 's, 'm, 'pm: 'm, 't, 'pt: 't> {
pub(crate) engine: &'e Engine,
pub scope: &'x mut Scope<'px>,
pub(crate) scope: &'x mut Scope<'px>,
pub(crate) mods: &'a mut Imports,
pub(crate) state: &'s mut State,
pub(crate) lib: &'m [&'pm Module],
@@ -546,6 +546,16 @@ impl<'e, 'x, 'px, 'a, 's, 'm, 'pm, 't, 'pt> EvalContext<'e, 'x, 'px, 'a, 's, 'm,
pub fn engine(&self) -> &'e Engine {
self.engine
}
/// The current [`Scope`].
#[inline(always)]
pub fn scope(&self) -> &Scope<'px> {
self.scope
}
/// Mutable reference to the current [`Scope`].
#[inline(always)]
pub fn scope_mut(&mut self) -> &mut &'x mut Scope<'px> {
&mut self.scope
}
/// _(INTERNALS)_ The current set of modules imported via `import` statements.
/// Available under the `internals` feature only.
#[cfg(feature = "internals")]
@@ -1822,7 +1832,7 @@ impl Engine {
Expr::Custom(custom, _) => {
let expressions = custom
.keywords()
.keywords
.iter()
.map(Into::into)
.collect::<StaticVec<_>>();