difftreelog
refactor drop OptionalContext marker
in: master
1 file changed
crates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth778use crate::{evaluate, typed::Typed, with_state, Context, Result, Thunk, Val};8use crate::{evaluate, typed::Typed, with_state, Context, Result, Thunk, Val};910/// Marker for arguments, which can be evaluated with context set to None11pub trait OptionalContext {}12913pub 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 {}413742#[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 {}252247253macro_rules! impl_args_like {248macro_rules! impl_args_like {254 ($count:expr; $($gen:ident)*) => {249 ($count:expr; $($gen:ident)*) => {286 false281 false287 }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 true330 }324 }331}325}332impl OptionalContext for () {}333326