git.delta.rocks / jrsonnet / refs/commits / 662289aa9d70

difftreelog

docs(macros) deny(missing_docs)

lvxlwrpyYaroslav Bolyukin2026-05-15parent: #ee32be6.patch.diff
in: master
docs(ir): visit_destruct_rest

2 files changed

modifiedcrates/jrsonnet-ir/src/visit.rsdiffbeforeafterboth
27 fn visit_import(&mut self, _as_expression: bool, _value: IStr) {}27 fn visit_import(&mut self, _as_expression: bool, _value: IStr) {}
28}28}
2929
30/// Use [`Visitor`] to recursively visit [`crate::DestructRest`].
30#[cfg(feature = "exp-destruct")]31#[cfg(feature = "exp-destruct")]
31pub fn visit_destruct_rest<V: Visitor>(_v: &mut V, destruct: &crate::DestructRest) {32pub fn visit_destruct_rest<V: Visitor>(_v: &mut V, destruct: &crate::DestructRest) {
32 match destruct {33 match destruct {
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
1//! Helper macros to support `jrsonnet-evaluator` usage.
2#![deny(missing_docs)]
3
1use std::string::String;4use std::string::String;
25
237 }240 }
238}241}
239242
243/// Create a `Builtin` implementation with the corresponding struct with the same name for the function definition.
244///
245/// Builtin functions might be used like closures by defining fields.
246///
247/// ```jsonnet
248/// #[builtin(fields(
249/// a: u32
250/// ))]
251/// fn curried_add(this: &curried_add, b: u32) -> u32 {
252/// this.a + b
253/// }
254///
255/// #[builtin]
256/// fn curry_add(a: u32) -> FuncVal {
257/// FuncVal::builtin(curried_add { a })
258/// }
259/// ```
240#[proc_macro_attribute]260#[proc_macro_attribute]
241pub fn builtin(261pub fn builtin(
242 attr: proc_macro::TokenStream,262 attr: proc_macro::TokenStream,
431 })451 })
432}452}
433453
454/// Derive for `Typed` macro, describes the object structure in jrsonnet type system.
434#[proc_macro_derive(Typed, attributes(typed))]455#[proc_macro_derive(Typed, attributes(typed))]
435pub fn derive_typed(item: proc_macro::TokenStream) -> proc_macro::TokenStream {456pub fn derive_typed(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
436 let input = parse_macro_input!(item as DeriveInput);457 let input = parse_macro_input!(item as DeriveInput);
440 Err(e) => e.to_compile_error().into(),461 Err(e) => e.to_compile_error().into(),
441 }462 }
442}463}
464/// Implement `IntoUntyped` for a struct, all the field values will be copied and converted using `IntoUntyped`.
443#[proc_macro_derive(IntoUntyped, attributes(typed))]465#[proc_macro_derive(IntoUntyped, attributes(typed))]
444pub fn derive_into_untyped(item: proc_macro::TokenStream) -> proc_macro::TokenStream {466pub fn derive_into_untyped(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
445 let input = parse_macro_input!(item as DeriveInput);467 let input = parse_macro_input!(item as DeriveInput);
449 Err(e) => e.to_compile_error().into(),471 Err(e) => e.to_compile_error().into(),
450 }472 }
451}473}
474/// Implement `FromUntyped` for a struct, all the field values will be populated from jsonnet values using `FromUntyped`.
452#[proc_macro_derive(FromUntyped, attributes(typed))]475#[proc_macro_derive(FromUntyped, attributes(typed))]
453pub fn derive_from_untyped(item: proc_macro::TokenStream) -> proc_macro::TokenStream {476pub fn derive_from_untyped(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
454 let input = parse_macro_input!(item as DeriveInput);477 let input = parse_macro_input!(item as DeriveInput);
551///574///
552/// Using `format!("literal with no codes").into()` is slower than just `"literal with no codes".into()`575/// Using `format!("literal with no codes").into()` is slower than just `"literal with no codes".into()`
553/// This macro looks for formatting codes in the input string, and uses576/// This macro looks for formatting codes in the input string, and uses
554/// `format!()` only when necessary577/// `format!()` only when necessary.
555#[proc_macro]578#[proc_macro]
556pub fn format_istr(input: proc_macro::TokenStream) -> proc_macro::TokenStream {579pub fn format_istr(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
557 let input = parse_macro_input!(input as FormatInput);580 let input = parse_macro_input!(input as FormatInput);
558 input.expand().into()581 input.expand().into()
559}582}
560583
561/// Create Thunk using closure syntax584/// Create `Thunk` value using closure syntax.
585///
586/// ```jsonnet
587/// Thunk!(move || evaluaate(ctx, expr))
588/// ```
562#[proc_macro]589#[proc_macro]
563#[allow(non_snake_case)]590#[allow(non_snake_case)]
564pub fn Thunk(input: proc_macro::TokenStream) -> proc_macro::TokenStream {591pub fn Thunk(input: proc_macro::TokenStream) -> proc_macro::TokenStream {