git.delta.rocks / jrsonnet / refs/commits / cbdee48b2528

difftreelog

refactor drop OptionalContext marker

wvzyqxsnYaroslav Bolyukin2026-03-21parent: #c0a2148.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth
77
8use crate::{evaluate, typed::Typed, with_state, Context, Result, Thunk, Val};8use crate::{evaluate, typed::Typed, with_state, Context, Result, Thunk, Val};
9
10/// Marker for arguments, which can be evaluated with context set to None
11pub trait OptionalContext {}
129
13pub trait ArgLike {10pub trait ArgLike {
14 fn evaluate_arg(&self, ctx: Context, tailstrict: bool) -> Result<Thunk<Val>>;11 fn evaluate_arg(&self, ctx: Context, tailstrict: bool) -> Result<Thunk<Val>>;
37 Ok(Thunk::evaluated(val))34 Ok(Thunk::evaluated(val))
38 }35 }
39}36}
40impl<T> OptionalContext for T where T: Typed + Clone {}
4137
42#[derive(Clone, Trace)]38#[derive(Clone, Trace)]
43pub enum TlaArg {39pub enum TlaArg {
248 self.is_empty()244 self.is_empty()
249 }245 }
250}246}
251impl<V, S> OptionalContext for HashMap<IStr, V, S> where V: ArgLike + OptionalContext {}
252247
253macro_rules! impl_args_like {248macro_rules! impl_args_like {
254 ($count:expr; $($gen:ident)*) => {249 ($count:expr; $($gen:ident)*) => {
286 false281 false
287 }282 }
288 }283 }
289 impl<$($gen: ArgLike,)*> OptionalContext for ($($gen,)*) where $($gen: OptionalContext),* {}
290 };284 };
291 ($count:expr; $($cur:ident)* @ $c:ident $($rest:ident)*) => {285 ($count:expr; $($cur:ident)* @ $c:ident $($rest:ident)*) => {
292 impl_args_like!($count; $($cur)*);286 impl_args_like!($count; $($cur)*);
329 true323 true
330 }324 }
331}325}
332impl OptionalContext for () {}
333326