diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
| commit | d763f0f5a6a700352ee8926c15c8e58624f705c9 (patch) | |
| tree | d287edfdab9793a796404516c7313689e4e69964 /src/eval/call.rs | |
| parent | 0f0416054f263b80ccec1a463ce4ab20913bdf71 (diff) | |
Split state and scopes, less ref-counting 🔀
Diffstat (limited to 'src/eval/call.rs')
| -rw-r--r-- | src/eval/call.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/eval/call.rs b/src/eval/call.rs index f47ee847..8e75f17c 100644 --- a/src/eval/call.rs +++ b/src/eval/call.rs @@ -8,7 +8,7 @@ impl Eval for Spanned<&ExprCall> { let name = &self.v.name.v; let span = self.v.name.span; - if let Some(value) = ctx.state.scope.get(name) { + if let Some(value) = ctx.scopes.get(name) { if let Value::Func(func) = value { let func = func.clone(); ctx.deco(Deco::Resolved.with_span(span)); @@ -90,10 +90,10 @@ impl Args { } /// Filter out and remove all convertible positional arguments. - pub fn filter<'a, T>( + pub fn filter<'a, 'b: 'a, T>( &'a mut self, - ctx: &'a mut EvalContext, - ) -> impl Iterator<Item = T> + 'a + ctx: &'a mut EvalContext<'b>, + ) -> impl Iterator<Item = T> + Captures<'a> + Captures<'b> where T: Cast<Spanned<Value>>, { @@ -130,6 +130,13 @@ impl Args { } } +// This is a workaround because `-> impl Trait + 'a + 'b` does not work. +// +// See also: https://github.com/rust-lang/rust/issues/49431 +#[doc(hidden)] +pub trait Captures<'a> {} +impl<'a, T: ?Sized> Captures<'a> for T {} + /// Cast the value into `T`, generating an error if the conversion fails. fn cast<T>(ctx: &mut EvalContext, value: Spanned<Value>) -> Option<T> where |
