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

difftreelog

build use `workspace.dependencies`

Yaroslav Bolyukin2022-10-26parent: #fe52b32.patch.diff
in: master

16 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -25,9 +25,9 @@
 
 [[package]]
 name = "anyhow"
-version = "1.0.57"
+version = "1.0.66"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
+checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
 
 [[package]]
 name = "atty"
@@ -48,9 +48,9 @@
 
 [[package]]
 name = "base64"
-version = "0.13.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
+checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
 
 [[package]]
 name = "bincode"
@@ -87,35 +87,33 @@
 
 [[package]]
 name = "clap"
-version = "3.2.8"
+version = "4.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
+checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b"
 dependencies = [
  "atty",
  "bitflags",
  "clap_derive",
  "clap_lex",
- "indexmap",
  "once_cell",
  "strsim",
  "termcolor",
- "textwrap",
 ]
 
 [[package]]
 name = "clap_complete"
-version = "3.2.3"
+version = "4.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ead064480dfc4880a10764488415a97fdd36a4cf1bb022d372f02e8faf8386e1"
+checksum = "dfe581a2035db4174cdbdc91265e1aba50f381577f0510d0ad36c7bc59cc84a3"
 dependencies = [
  "clap",
 ]
 
 [[package]]
 name = "clap_derive"
-version = "3.2.7"
+version = "4.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902"
+checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3"
 dependencies = [
  "heck",
  "proc-macro-error",
@@ -126,9 +124,9 @@
 
 [[package]]
 name = "clap_lex"
-version = "0.2.4"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
 dependencies = [
  "os_str_bytes",
 ]
@@ -144,9 +142,9 @@
 
 [[package]]
 name = "getrandom"
-version = "0.2.6"
+version = "0.2.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
+checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
 dependencies = [
  "cfg-if 1.0.0",
  "libc",
@@ -155,15 +153,9 @@
 
 [[package]]
 name = "hashbrown"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
-
-[[package]]
-name = "hashbrown"
-version = "0.12.1"
+version = "0.12.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
 dependencies = [
  "ahash",
 ]
@@ -185,23 +177,23 @@
 
 [[package]]
 name = "indexmap"
-version = "1.8.2"
+version = "1.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
+checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
 dependencies = [
  "autocfg",
- "hashbrown 0.11.2",
+ "hashbrown",
 ]
 
 [[package]]
 name = "itoa"
-version = "1.0.2"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
+checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
 
 [[package]]
 name = "jrsonnet"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "clap",
  "clap_complete",
@@ -215,7 +207,7 @@
 
 [[package]]
 name = "jrsonnet-cli"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "clap",
  "jrsonnet-evaluator",
@@ -226,12 +218,12 @@
 
 [[package]]
 name = "jrsonnet-evaluator"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "annotate-snippets",
  "anyhow",
  "bincode",
- "hashbrown 0.12.1",
+ "hashbrown",
  "jrsonnet-gcmodule",
  "jrsonnet-interner",
  "jrsonnet-macros",
@@ -268,9 +260,9 @@
 
 [[package]]
 name = "jrsonnet-interner"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
- "hashbrown 0.12.1",
+ "hashbrown",
  "jrsonnet-gcmodule",
  "rustc-hash",
  "serde",
@@ -279,7 +271,7 @@
 
 [[package]]
 name = "jrsonnet-macros"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -288,7 +280,7 @@
 
 [[package]]
 name = "jrsonnet-parser"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "jrsonnet-gcmodule",
  "jrsonnet-interner",
@@ -300,7 +292,7 @@
 
 [[package]]
 name = "jrsonnet-stdlib"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "base64",
  "bincode",
@@ -317,7 +309,7 @@
 
 [[package]]
 name = "jrsonnet-types"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "jrsonnet-gcmodule",
  "peg",
@@ -325,13 +317,13 @@
 
 [[package]]
 name = "libc"
-version = "0.2.126"
+version = "0.2.137"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
+checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
 
 [[package]]
 name = "libjsonnet"
-version = "0.4.2"
+version = "0.5.0"
 dependencies = [
  "jrsonnet-evaluator",
  "jrsonnet-gcmodule",
@@ -381,15 +373,15 @@
 
 [[package]]
 name = "once_cell"
-version = "1.12.0"
+version = "1.15.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
+checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
 
 [[package]]
 name = "os_str_bytes"
-version = "6.1.0"
+version = "6.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
+checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
 
 [[package]]
 name = "parking_lot"
@@ -423,9 +415,9 @@
 
 [[package]]
 name = "peg"
-version = "0.8.0"
+version = "0.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af728fe826811af3b38c37e93de6d104485953ea373d656eebae53d6987fcd2c"
+checksum = "a07f2cafdc3babeebc087e499118343442b742cc7c31b4d054682cc598508554"
 dependencies = [
  "peg-macros",
  "peg-runtime",
@@ -433,9 +425,9 @@
 
 [[package]]
 name = "peg-macros"
-version = "0.8.0"
+version = "0.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4536be147b770b824895cbad934fccce8e49f14b4c4946eaa46a6e4a12fcdc16"
+checksum = "4a90084dc05cf0428428e3d12399f39faad19b0909f64fb9170c9fdd6d9cd49b"
 dependencies = [
  "peg-runtime",
  "proc-macro2",
@@ -444,9 +436,9 @@
 
 [[package]]
 name = "peg-runtime"
-version = "0.8.0"
+version = "0.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9b0efd3ba03c3a409d44d60425f279ec442bcf0b9e63ff4e410da31c8b0f69f"
+checksum = "9fa00462b37ead6d11a82c9d568b26682d78e0477dc02d1966c013af80969739"
 
 [[package]]
 name = "proc-macro-error"
@@ -474,18 +466,18 @@
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.39"
+version = "1.0.47"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
+checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.18"
+version = "1.0.21"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
+checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
 dependencies = [
  "proc-macro2",
 ]
@@ -504,9 +496,9 @@
 
 [[package]]
 name = "ryu"
-version = "1.0.10"
+version = "1.0.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
+checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
 
 [[package]]
 name = "scopeguard"
@@ -516,18 +508,18 @@
 
 [[package]]
 name = "serde"
-version = "1.0.142"
+version = "1.0.147"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2"
+checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.142"
+version = "1.0.147"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e"
+checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -536,9 +528,9 @@
 
 [[package]]
 name = "serde_json"
-version = "1.0.82"
+version = "1.0.87"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
+checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
 dependencies = [
  "itoa",
  "ryu",
@@ -559,9 +551,9 @@
 
 [[package]]
 name = "smallvec"
-version = "1.8.0"
+version = "1.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
+checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
 
 [[package]]
 name = "static_assertions"
@@ -599,9 +591,9 @@
 
 [[package]]
 name = "syn"
-version = "1.0.96"
+version = "1.0.103"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
+checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -628,25 +620,19 @@
 ]
 
 [[package]]
-name = "textwrap"
-version = "0.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
-
-[[package]]
 name = "thiserror"
-version = "1.0.31"
+version = "1.0.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
+checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.31"
+version = "1.0.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
+checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -655,15 +641,15 @@
 
 [[package]]
 name = "unicode-ident"
-version = "1.0.0"
+version = "1.0.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
+checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
 
 [[package]]
 name = "unicode-width"
-version = "0.1.9"
+version = "0.1.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
+checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
 
 [[package]]
 name = "version_check"
@@ -673,9 +659,9 @@
 
 [[package]]
 name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
+version = "0.11.0+wasi-snapshot-preview1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 
 [[package]]
 name = "winapi"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,16 @@
 [workspace]
+package.version = "0.5.0"
 members = ["crates/*", "bindings/jsonnet", "cmds/jrsonnet", "tests"]
 
+[workspace.dependencies]
+jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0" }
+jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0" }
+jrsonnet-parser = { path = "./crates/jrsonnet-parser", version = "0.5.0" }
+jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0" }
+jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0" }
+jrsonnet-cli = { path = "./crates/jrsonnet-cli", version = "0.5.0" }
+jrsonnet-types = { path = "./crates/jrsonnet-types", version = "0.5.0" }
+
 [profile.test]
 opt-level = 1
 
modifiedbindings/jsonnet/Cargo.tomldiffbeforeafterboth
--- a/bindings/jsonnet/Cargo.toml
+++ b/bindings/jsonnet/Cargo.toml
@@ -1,16 +1,16 @@
 [package]
 name = "libjsonnet"
 description = "Rust implementation of libjsonnet.so"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
 publish = false
 
 [dependencies]
-jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2" }
-jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
-jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
+jrsonnet-evaluator.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-stdlib.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 [lib]
modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet"
 description = "Rust jsonnet implementation"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -21,9 +21,9 @@
 legacy-this-file = ["jrsonnet-cli/legacy-this-file"]
 
 [dependencies]
-jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2" }
-jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
-jrsonnet-cli = { path = "../../crates/jrsonnet-cli", version = "0.4.2" }
+jrsonnet-evaluator.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-cli.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 mimallocator = { version = "0.1.3", optional = true }
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-cli"
 description = "Utilities for building jrsonnet CLIs"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -14,11 +14,9 @@
 legacy-this-file = ["jrsonnet-stdlib/legacy-this-file"]
 
 [dependencies]
-jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2", features = [
-    "explaining-traces",
-] }
-jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
+jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }
+jrsonnet-parser.workspace = true
+jrsonnet-stdlib.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
-jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
 
 clap = { version = "4.0", features = ["derive"] }
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-evaluator"
 description = "jsonnet interpreter"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -24,10 +24,10 @@
 nightly = []
 
 [dependencies]
-jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
-jrsonnet-types = { path = "../jrsonnet-types", version = "0.4.2" }
-jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
+jrsonnet-interner.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-types.workspace = true
+jrsonnet-macros.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 pathdiff = "0.2.1"
modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/evaluate/destructure.rs
1use jrsonnet_gcmodule::Trace;2use jrsonnet_interner::IStr;3use jrsonnet_parser::{BindSpec, Destruct, LocExpr, ParamsDesc};45use crate::{6	error::{Error::*, Result},7	evaluate, evaluate_method, evaluate_named,8	gc::GcHashMap,9	tb, throw,10	val::ThunkValue,11	Context, Pending, Thunk, Val,12};1314#[allow(clippy::too_many_lines)]15#[allow(unused_variables)]16pub fn destruct(17	d: &Destruct,18	parent: Thunk<Val>,19	fctx: Pending<Context>,20	new_bindings: &mut GcHashMap<IStr, Thunk<Val>>,21) -> Result<()> {22	match d {23		Destruct::Full(v) => {24			let old = new_bindings.insert(v.clone(), parent);25			if old.is_some() {26				throw!(DuplicateLocalVar(v.clone()))27			}28		}29		#[cfg(feature = "exp-destruct")]30		Destruct::Skip => {}31		#[cfg(feature = "exp-destruct")]32		Destruct::Array { start, rest, end } => {33			use jrsonnet_parser::DestructRest;3435			use crate::{throw, val::ArrValue};3637			#[derive(Trace)]38			struct DataThunk {39				parent: Thunk<Val>,40				min_len: usize,41				has_rest: bool,42			}43			impl ThunkValue for DataThunk {44				type Output = ArrValue;4546				fn get(self: Box<Self>, s: State) -> Result<Self::Output> {47					let v = self.parent.evaluate(s)?;48					let arr = match v {49						Val::Arr(a) => a,50						_ => throw!("expected array"),51					};52					if !self.has_rest {53						if arr.len() != self.min_len {54							throw!("expected {} elements, got {}", self.min_len, arr.len())55						}56					} else if arr.len() < self.min_len {57						throw!(58							"expected at least {} elements, but array was only {}",59							self.min_len,60							arr.len()61						)62					}63					Ok(arr)64				}65			}6667			let full = Thunk::new(tb!(DataThunk {68				min_len: start.len() + end.len(),69				has_rest: rest.is_some(),70				parent,71			}));7273			{74				#[derive(Trace)]75				struct BaseThunk {76					full: Thunk<ArrValue>,77					index: usize,78				}79				impl ThunkValue for BaseThunk {80					type Output = Val;8182					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {83						let full = self.full.evaluate(s.clone())?;84						Ok(full.get(s, self.index)?.expect("length is checked"))85					}86				}87				for (i, d) in start.iter().enumerate() {88					destruct(89						d,90						Thunk::new(tb!(BaseThunk {91							full: full.clone(),92							index: i,93						})),94						fctx.clone(),95						new_bindings,96					)?;97				}98			}99100			match rest {101				Some(DestructRest::Keep(v)) => {102					#[derive(Trace)]103					struct RestThunk {104						full: Thunk<ArrValue>,105						start: usize,106						end: usize,107					}108					impl ThunkValue for RestThunk {109						type Output = Val;110111						fn get(self: Box<Self>, s: State) -> Result<Self::Output> {112							let full = self.full.evaluate(s)?;113							let to = full.len() - self.end;114							Ok(Val::Arr(full.slice(Some(self.start), Some(to), None)))115						}116					}117118					destruct(119						&Destruct::Full(v.clone()),120						Thunk::new(tb!(RestThunk {121							full: full.clone(),122							start: start.len(),123							end: end.len(),124						})),125						fctx.clone(),126						new_bindings,127					)?;128				}129				Some(DestructRest::Drop) => {}130				None => {}131			}132133			{134				#[derive(Trace)]135				struct EndThunk {136					full: Thunk<ArrValue>,137					index: usize,138					end: usize,139				}140				impl ThunkValue for EndThunk {141					type Output = Val;142143					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {144						let full = self.full.evaluate(s.clone())?;145						Ok(full146							.get(s, full.len() - self.end + self.index)?147							.expect("length is checked"))148					}149				}150				for (i, d) in end.iter().enumerate() {151					destruct(152						d,153						Thunk::new(tb!(EndThunk {154							full: full.clone(),155							index: i,156							end: end.len(),157						})),158						fctx.clone(),159						new_bindings,160					)?;161				}162			}163		}164		#[cfg(feature = "exp-destruct")]165		Destruct::Object { fields, rest } => {166			use crate::{obj::ObjValue, throw};167168			#[derive(Trace)]169			struct DataThunk {170				parent: Thunk<Val>,171				field_names: Vec<IStr>,172				has_rest: bool,173			}174			impl ThunkValue for DataThunk {175				type Output = ObjValue;176177				fn get(self: Box<Self>, s: State) -> Result<Self::Output> {178					let v = self.parent.evaluate(s)?;179					let obj = match v {180						Val::Obj(o) => o,181						_ => throw!("expected object"),182					};183					for field in &self.field_names {184						if !obj.has_field_ex(field.clone(), true) {185							throw!("missing field: {}", field);186						}187					}188					if !self.has_rest {189						let len = obj.len();190						if len != self.field_names.len() {191							throw!("too many fields, and rest not found");192						}193					}194					Ok(obj)195				}196			}197			let field_names: Vec<_> = fields198				.iter()199				.filter(|f| f.2.is_none())200				.map(|f| f.0.clone())201				.collect();202			let full = Thunk::new(tb!(DataThunk {203				parent,204				field_names: field_names.clone(),205				has_rest: rest.is_some()206			}));207208			for (field, d, default) in fields {209				#[derive(Trace)]210				struct FieldThunk {211					full: Thunk<ObjValue>,212					field: IStr,213					default: Option<(Pending<Context>, LocExpr)>,214				}215				impl ThunkValue for FieldThunk {216					type Output = Val;217218					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {219						let full = self.full.evaluate(s.clone())?;220						if let Some(field) = full.get(s.clone(), self.field)? {221							Ok(field)222						} else {223							let (fctx, expr) = self.default.as_ref().expect("shape is checked");224							Ok(evaluate(s, fctx.clone().unwrap(), &expr)?)225						}226					}227				}228				let value = Thunk::new(tb!(FieldThunk {229					full: full.clone(),230					field: field.clone(),231					default: default.clone().map(|e| (fctx.clone(), e)),232				}));233				if let Some(d) = d {234					destruct(d, value, fctx.clone(), new_bindings)?;235				} else {236					destruct(237						&Destruct::Full(field.clone()),238						value,239						fctx.clone(),240						new_bindings,241					)?;242				}243			}244		}245	}246	Ok(())247}248249pub fn evaluate_dest(250	d: &BindSpec,251	fctx: Pending<Context>,252	new_bindings: &mut GcHashMap<IStr, Thunk<Val>>,253) -> Result<()> {254	match d {255		BindSpec::Field { into, value } => {256			#[derive(Trace)]257			struct EvaluateThunkValue {258				name: Option<IStr>,259				fctx: Pending<Context>,260				expr: LocExpr,261			}262			impl ThunkValue for EvaluateThunkValue {263				type Output = Val;264				fn get(self: Box<Self>) -> Result<Self::Output> {265					self.name.map_or_else(266						|| evaluate(self.fctx.unwrap(), &self.expr),267						|name| evaluate_named(self.fctx.unwrap(), &self.expr, name),268					)269				}270			}271			let data = Thunk::new(tb!(EvaluateThunkValue {272				name: into.name(),273				fctx: fctx.clone(),274				expr: value.clone(),275			}));276			destruct(into, data, fctx, new_bindings)?;277		}278		BindSpec::Function {279			name,280			params,281			value,282		} => {283			#[derive(Trace)]284			struct MethodThunk {285				fctx: Pending<Context>,286				name: IStr,287				params: ParamsDesc,288				value: LocExpr,289			}290			impl ThunkValue for MethodThunk {291				type Output = Val;292293				fn get(self: Box<Self>) -> Result<Self::Output> {294					Ok(evaluate_method(295						self.fctx.unwrap(),296						self.name,297						self.params,298						self.value,299					))300				}301			}302303			let old = new_bindings.insert(304				name.clone(),305				Thunk::new(tb!(MethodThunk {306					fctx,307					name: name.clone(),308					params: params.clone(),309					value: value.clone()310				})),311			);312			if old.is_some() {313				throw!(DuplicateLocalVar(name.clone()))314			}315		}316	}317	Ok(())318}
after · crates/jrsonnet-evaluator/src/evaluate/destructure.rs
1use jrsonnet_gcmodule::Trace;2use jrsonnet_interner::IStr;3use jrsonnet_parser::{BindSpec, Destruct, LocExpr, ParamsDesc};45use crate::{6	error::{Error::*, Result},7	evaluate, evaluate_method, evaluate_named,8	gc::GcHashMap,9	tb, throw,10	val::ThunkValue,11	Context, Pending, Thunk, Val,12};1314#[allow(clippy::too_many_lines)]15#[allow(unused_variables)]16pub fn destruct(17	d: &Destruct,18	parent: Thunk<Val>,19	fctx: Pending<Context>,20	new_bindings: &mut GcHashMap<IStr, Thunk<Val>>,21) -> Result<()> {22	match d {23		Destruct::Full(v) => {24			let old = new_bindings.insert(v.clone(), parent);25			if old.is_some() {26				throw!(DuplicateLocalVar(v.clone()))27			}28		}29		#[cfg(feature = "exp-destruct")]30		Destruct::Skip => {}31		#[cfg(feature = "exp-destruct")]32		Destruct::Array { start, rest, end } => {33			use jrsonnet_parser::DestructRest;3435			use crate::val::ArrValue;3637			#[derive(Trace)]38			struct DataThunk {39				parent: Thunk<Val>,40				min_len: usize,41				has_rest: bool,42			}43			impl ThunkValue for DataThunk {44				type Output = ArrValue;4546				fn get(self: Box<Self>) -> Result<Self::Output> {47					let v = self.parent.evaluate()?;48					let arr = match v {49						Val::Arr(a) => a,50						_ => throw!("expected array"),51					};52					if !self.has_rest {53						if arr.len() != self.min_len {54							throw!("expected {} elements, got {}", self.min_len, arr.len())55						}56					} else if arr.len() < self.min_len {57						throw!(58							"expected at least {} elements, but array was only {}",59							self.min_len,60							arr.len()61						)62					}63					Ok(arr)64				}65			}6667			let full = Thunk::new(tb!(DataThunk {68				min_len: start.len() + end.len(),69				has_rest: rest.is_some(),70				parent,71			}));7273			{74				#[derive(Trace)]75				struct BaseThunk {76					full: Thunk<ArrValue>,77					index: usize,78				}79				impl ThunkValue for BaseThunk {80					type Output = Val;8182					fn get(self: Box<Self>) -> Result<Self::Output> {83						let full = self.full.evaluate()?;84						Ok(full.get(self.index)?.expect("length is checked"))85					}86				}87				for (i, d) in start.iter().enumerate() {88					destruct(89						d,90						Thunk::new(tb!(BaseThunk {91							full: full.clone(),92							index: i,93						})),94						fctx.clone(),95						new_bindings,96					)?;97				}98			}99100			match rest {101				Some(DestructRest::Keep(v)) => {102					#[derive(Trace)]103					struct RestThunk {104						full: Thunk<ArrValue>,105						start: usize,106						end: usize,107					}108					impl ThunkValue for RestThunk {109						type Output = Val;110111						fn get(self: Box<Self>) -> Result<Self::Output> {112							let full = self.full.evaluate()?;113							let to = full.len() - self.end;114							Ok(Val::Arr(full.slice(Some(self.start), Some(to), None)))115						}116					}117118					destruct(119						&Destruct::Full(v.clone()),120						Thunk::new(tb!(RestThunk {121							full: full.clone(),122							start: start.len(),123							end: end.len(),124						})),125						fctx.clone(),126						new_bindings,127					)?;128				}129				Some(DestructRest::Drop) => {}130				None => {}131			}132133			{134				#[derive(Trace)]135				struct EndThunk {136					full: Thunk<ArrValue>,137					index: usize,138					end: usize,139				}140				impl ThunkValue for EndThunk {141					type Output = Val;142143					fn get(self: Box<Self>) -> Result<Self::Output> {144						let full = self.full.evaluate()?;145						Ok(full146							.get(full.len() - self.end + self.index)?147							.expect("length is checked"))148					}149				}150				for (i, d) in end.iter().enumerate() {151					destruct(152						d,153						Thunk::new(tb!(EndThunk {154							full: full.clone(),155							index: i,156							end: end.len(),157						})),158						fctx.clone(),159						new_bindings,160					)?;161				}162			}163		}164		#[cfg(feature = "exp-destruct")]165		Destruct::Object { fields, rest } => {166			use crate::obj::ObjValue;167168			#[derive(Trace)]169			struct DataThunk {170				parent: Thunk<Val>,171				field_names: Vec<IStr>,172				has_rest: bool,173			}174			impl ThunkValue for DataThunk {175				type Output = ObjValue;176177				fn get(self: Box<Self>) -> Result<Self::Output> {178					let v = self.parent.evaluate()?;179					let obj = match v {180						Val::Obj(o) => o,181						_ => throw!("expected object"),182					};183					for field in &self.field_names {184						if !obj.has_field_ex(field.clone(), true) {185							throw!("missing field: {}", field);186						}187					}188					if !self.has_rest {189						let len = obj.len();190						if len != self.field_names.len() {191							throw!("too many fields, and rest not found");192						}193					}194					Ok(obj)195				}196			}197			let field_names: Vec<_> = fields198				.iter()199				.filter(|f| f.2.is_none())200				.map(|f| f.0.clone())201				.collect();202			let full = Thunk::new(tb!(DataThunk {203				parent,204				field_names: field_names.clone(),205				has_rest: rest.is_some()206			}));207208			for (field, d, default) in fields {209				#[derive(Trace)]210				struct FieldThunk {211					full: Thunk<ObjValue>,212					field: IStr,213					default: Option<(Pending<Context>, LocExpr)>,214				}215				impl ThunkValue for FieldThunk {216					type Output = Val;217218					fn get(self: Box<Self>) -> Result<Self::Output> {219						let full = self.full.evaluate()?;220						if let Some(field) = full.get(self.field)? {221							Ok(field)222						} else {223							let (fctx, expr) = self.default.as_ref().expect("shape is checked");224							Ok(evaluate(fctx.clone().unwrap(), &expr)?)225						}226					}227				}228				let value = Thunk::new(tb!(FieldThunk {229					full: full.clone(),230					field: field.clone(),231					default: default.clone().map(|e| (fctx.clone(), e)),232				}));233				if let Some(d) = d {234					destruct(d, value, fctx.clone(), new_bindings)?;235				} else {236					destruct(237						&Destruct::Full(field.clone()),238						value,239						fctx.clone(),240						new_bindings,241					)?;242				}243			}244		}245	}246	Ok(())247}248249pub fn evaluate_dest(250	d: &BindSpec,251	fctx: Pending<Context>,252	new_bindings: &mut GcHashMap<IStr, Thunk<Val>>,253) -> Result<()> {254	match d {255		BindSpec::Field { into, value } => {256			#[derive(Trace)]257			struct EvaluateThunkValue {258				name: Option<IStr>,259				fctx: Pending<Context>,260				expr: LocExpr,261			}262			impl ThunkValue for EvaluateThunkValue {263				type Output = Val;264				fn get(self: Box<Self>) -> Result<Self::Output> {265					self.name.map_or_else(266						|| evaluate(self.fctx.unwrap(), &self.expr),267						|name| evaluate_named(self.fctx.unwrap(), &self.expr, name),268					)269				}270			}271			let data = Thunk::new(tb!(EvaluateThunkValue {272				name: into.name(),273				fctx: fctx.clone(),274				expr: value.clone(),275			}));276			destruct(into, data, fctx, new_bindings)?;277		}278		BindSpec::Function {279			name,280			params,281			value,282		} => {283			#[derive(Trace)]284			struct MethodThunk {285				fctx: Pending<Context>,286				name: IStr,287				params: ParamsDesc,288				value: LocExpr,289			}290			impl ThunkValue for MethodThunk {291				type Output = Val;292293				fn get(self: Box<Self>) -> Result<Self::Output> {294					Ok(evaluate_method(295						self.fctx.unwrap(),296						self.name,297						self.params,298						self.value,299					))300				}301			}302303			let old = new_bindings.insert(304				name.clone(),305				Thunk::new(tb!(MethodThunk {306					fctx,307					name: name.clone(),308					params: params.clone(),309					value: value.clone()310				})),311			);312			if old.is_some() {313				throw!(DuplicateLocalVar(name.clone()))314			}315		}316	}317	Ok(())318}
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -178,7 +178,10 @@
 			}
 			Val::Obj(obj) => {
 				let mut map = serializer.serialize_map(Some(obj.len()))?;
-				for (field, value) in obj.iter() {
+				for (field, value) in obj.iter(
+					#[cfg(feature = "exp-preserve-order")]
+					true,
+				) {
 					let mut serde_error = None;
 					// TODO: rewrite using try{} after stabilization
 					State::push_description(
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -368,8 +368,14 @@
 			.map_or(false, |v| v.is_visible())
 	}
 
-	pub fn iter(&self) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {
-		let fields = self.fields();
+	pub fn iter(
+		&self,
+		#[cfg(feature = "exp-preserve-order")] preserve_order: bool,
+	) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {
+		let fields = self.fields(
+			#[cfg(feature = "exp-preserve-order")]
+			preserve_order,
+		);
 		fields.into_iter().map(|field| {
 			(
 				field.clone(),
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -625,6 +625,7 @@
 pub fn format_arr(str: &str, mut values: &[Val]) -> Result<String> {
 	let codes = parse_codes(str)?;
 	let mut out = String::new();
+	let value_count = values.len();
 
 	for code in codes {
 		match code {
@@ -673,6 +674,13 @@
 		}
 	}
 
+	if !values.is_empty() {
+		throw!(
+			"too many values to format, expected {value_count}, got {}",
+			value_count + values.len()
+		)
+	}
+
 	Ok(out)
 }
 
modifiedcrates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-interner"
 description = "Jrsonnet string interning"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -255,9 +255,7 @@
 		let mut pool = pool.borrow_mut();
 		let entry = pool.raw_entry_mut().from_key(bytes);
 		match entry {
-			hashbrown::hash_map::RawEntryMut::Occupied(mut i) => {
-				IBytes(i.get_key_value().0.clone())
-			}
+			hashbrown::hash_map::RawEntryMut::Occupied(i) => IBytes(i.get_key_value().0.clone()),
 			hashbrown::hash_map::RawEntryMut::Vacant(e) => {
 				let (k, _) = e.insert(Inner::new_bytes(bytes), ());
 				IBytes(k.clone())
modifiedcrates/jrsonnet-macros/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-macros/Cargo.toml
+++ b/crates/jrsonnet-macros/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "jrsonnet-macros"
-version = "0.4.2"
+version.workspace = true
 edition = "2021"
 
 [lib]
modifiedcrates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-parser"
 description = "jsonnet language parser and AST"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -26,7 +26,7 @@
 serde = ["dep:serde"]
 
 [dependencies]
-jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
+jrsonnet-interner.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 static_assertions = "1.1"
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-stdlib"
 description = "jsonnet standard library packaged as crate"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -17,9 +17,9 @@
 exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
 
 [dependencies]
-jrsonnet-evaluator = { path = "../jrsonnet-evaluator", version = "0.4.2" }
-jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
+jrsonnet-evaluator.workspace = true
+jrsonnet-macros.workspace = true
+jrsonnet-parser.workspace = true
 jrsonnet-gcmodule = "0.3.4"
 
 # Used for stdlib AST serialization
@@ -37,5 +37,5 @@
 serde_yaml_with_quirks = "0.8.24"
 
 [build-dependencies]
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
+jrsonnet-parser.workspace = true
 structdump = { version = "0.2.0", features = ["derive"] }
modifiedcrates/jrsonnet-types/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-types"
 description = "Jrsonnet type system definition"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"