From ca621dd03a4753b7855f4d3f135b5070b7aef5c6 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Mon, 13 Nov 2023 23:32:52 +0100 Subject: [PATCH] Simplify Rust executor (#119) --- executors/rust/Cargo.lock | 359 +++++++++++++++++++++------- executors/rust/Cargo.toml | 32 +-- executors/rust/src/collator.rs | 4 +- executors/rust/src/decimalfmt.rs | 13 +- executors/rust/src/displaynames.rs | 10 +- executors/rust/src/langnames.rs | 17 +- executors/rust/src/likelysubtags.rs | 10 +- executors/rust/src/main.rs | 14 +- executors/rust/src/numberfmt.rs | 44 ++-- 9 files changed, 325 insertions(+), 178 deletions(-) diff --git a/executors/rust/Cargo.lock b/executors/rust/Cargo.lock index 9d088246..dde17a58 100644 --- a/executors/rust/Cargo.lock +++ b/executors/rust/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -28,6 +34,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "calendrical_calculations" version = "0.1.0" @@ -38,6 +50,12 @@ dependencies = [ "displaydoc", ] +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "core_maths" version = "0.1.0" @@ -47,6 +65,24 @@ dependencies = [ "libm", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + [[package]] name = "databake" version = "0.1.6" @@ -97,6 +133,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "elsa" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714f766f3556b44e7e4776ad133fcc3445a489517c25c704ace411bb14790194" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "env_logger" version = "0.9.3" @@ -110,30 +155,31 @@ dependencies = [ "termcolor", ] +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "executor" version = "0.1.0" dependencies = [ - "databake", "env_logger", "fixed_decimal", "icu", "icu_compactdecimal", - "icu_decimal", + "icu_datagen", "icu_displaynames", - "icu_locid", - "icu_locid_transform", - "icu_plurals", - "icu_provider", - "icu_testdata", "json", "log", "rustc_version_runtime", "serde", "serde_json", - "substring", "writeable", - "zerovec", ] [[package]] @@ -147,6 +193,16 @@ dependencies = [ "writeable", ] +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -186,7 +242,6 @@ dependencies = [ "icu_relativetime", "icu_segmenter", "icu_timezone", - "icu_transliterate", ] [[package]] @@ -196,6 +251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b520c5675775e3838447c33fc55bf558148c6824ef0d20ff7a9e0df7345a281c" dependencies = [ "calendrical_calculations", + "databake", "displaydoc", "icu_calendar_data", "icu_locid", @@ -219,6 +275,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976068d7759293cbd9daa0d1669618bb9094c7ee54e546cd8b877dd4fe59007a" dependencies = [ + "databake", "displaydoc", "icu_casemap_data", "icu_collections", @@ -236,12 +293,23 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1251070c14d5b94cd00f97025e9cedce6a6eeb39485e2a226c58432cc4f72ffd" +[[package]] +name = "icu_codepointtrie_builder" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872a3fcc14248bb28572e1340fc23c14c0bcc083d1660743a76c4121e7fcb859" +dependencies = [ + "icu_collections", + "toml", +] + [[package]] name = "icu_collator" version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be493c81154545a00fc5196e814cae0e1470bc696d518b5df877049aa6bcefe1" dependencies = [ + "databake", "displaydoc", "icu_collator_data", "icu_collections", @@ -269,6 +337,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3907b2246e8dd5a29ead8a965e7c0c8a90e9b928e614a4279257d45c5e553e91" dependencies = [ + "databake", "displaydoc", "serde", "yoke", @@ -299,12 +368,55 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51cc4515902110b79d180c561c13b87e5b42bad85edf719a1d59ec713cd6ccf7" +[[package]] +name = "icu_datagen" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212acb6e6f3793755dbd6785e95c0fa5048c43a44e817154cdfb909f72afb57d" +dependencies = [ + "displaydoc", + "elsa", + "icu_calendar", + "icu_casemap", + "icu_codepointtrie_builder", + "icu_collator", + "icu_collections", + "icu_datetime", + "icu_decimal", + "icu_list", + "icu_locid", + "icu_locid_transform", + "icu_normalizer", + "icu_plurals", + "icu_properties", + "icu_provider", + "icu_provider_adapters", + "icu_segmenter", + "icu_timezone", + "itertools", + "log", + "memchr", + "ndarray", + "once_cell", + "serde", + "serde-aux", + "serde_json", + "tinystr", + "toml", + "twox-hash", + "writeable", + "zerotrie", + "zerovec", + "zip", +] + [[package]] name = "icu_datetime" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f5bf2e6dd961b59ee5935070220915db6cf0ab5137de362964f800c2b7d14fa" dependencies = [ + "databake", "displaydoc", "either", "fixed_decimal", @@ -336,6 +448,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1986a0b7df834aaddb911b4593c990950ac5606fc83ce9aad4311be80f51e81a" dependencies = [ + "databake", "displaydoc", "fixed_decimal", "icu_decimal_data", @@ -362,7 +475,6 @@ dependencies = [ "icu_locid", "icu_locid_transform", "icu_provider", - "serde", "tinystr", "zerovec", ] @@ -379,6 +491,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1a44bbed77a7e7b555f9d7dd4b43f75ec1402b438a901d20451943d50cbd90" dependencies = [ + "databake", "deduplicating_array", "displaydoc", "icu_list_data", @@ -401,6 +514,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f284eb342dc49d3e9d9f3b188489d76b5d22dfb1d1a5e0d1941811253bac625c" dependencies = [ + "databake", "displaydoc", "litemap", "serde", @@ -415,6 +529,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6551daf80882d8e68eee186cc19e132d8bde1b1f059a79b93384a5ca0e8fc5e7" dependencies = [ + "databake", "displaydoc", "icu_locid", "icu_locid_transform_data", @@ -436,6 +551,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080fc33a720d50a7342b0c58df010fbcfb842d6f78ef81555f8b1ac6bba57d3c" dependencies = [ + "databake", "displaydoc", "icu_collections", "icu_normalizer_data", @@ -461,6 +577,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20556516b8be2b2f5dc3d6b23884b65c5c59ed8be0b44c419e4808c9b0792fce" dependencies = [ + "databake", "displaydoc", "fixed_decimal", "icu_locid", @@ -483,6 +600,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3477ae70f8ca8dc08ff7574b5398ed0a2f2e4e6b66bdff2558a92ed67e262be1" dependencies = [ + "databake", "displaydoc", "icu_collections", "icu_locid_transform", @@ -505,9 +623,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68acdef80034b5e35d8524e9817479d389a4f9774f3f0cbe1bf3884d80fd5934" dependencies = [ + "databake", "displaydoc", + "erased-serde", "icu_locid", "icu_provider_macros", + "log", "serde", "stable_deref_trait", "tinystr", @@ -554,7 +675,6 @@ dependencies = [ "icu_plurals", "icu_provider", "icu_relativetime_data", - "serde", "writeable", "zerovec", ] @@ -572,6 +692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcb3c1981ce2187a745f391a741cb14e77453325acb3b2e014b05da51c0a39f2" dependencies = [ "core_maths", + "databake", "displaydoc", "icu_collections", "icu_locid", @@ -588,39 +709,13 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9703f6713044d1c0a1335a6d78ffece4c9380582416ace6feeb608e84d279fc7" -[[package]] -name = "icu_testdata" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "450f30cfb667892b510b3a050ad740e23625bfdfb6f73967baabfaeb4e7aa442" -dependencies = [ - "icu_calendar", - "icu_collator", - "icu_collections", - "icu_compactdecimal", - "icu_datetime", - "icu_decimal", - "icu_displaynames", - "icu_list", - "icu_locid", - "icu_locid_transform", - "icu_normalizer", - "icu_plurals", - "icu_properties", - "icu_provider", - "icu_provider_adapters", - "icu_segmenter", - "icu_timezone", - "zerotrie", - "zerovec", -] - [[package]] name = "icu_timezone" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e6401cd210ccda98b2e7fc707831b29c6efe319efbbec460f957b6f331f626" dependencies = [ + "databake", "displaydoc", "icu_calendar", "icu_locid", @@ -639,34 +734,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7e214a653bac59b768c42f82d252f13af95e8a9cb07b6108b8bc723c561b43" [[package]] -name = "icu_transliterate" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4bdf006774b5a5898d97af6c95b148d34cd5c87cbed00610ff873e5b5885e28" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid", - "icu_normalizer", - "icu_properties", - "icu_provider", - "icu_unicodeset_parse", - "litemap", - "serde", - "zerovec", -] - -[[package]] -name = "icu_unicodeset_parse" -version = "0.1.1" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2c3c1ab072cb9ec2dfb377ed7be07bf1bdce055b8324ba6392323f588c38c5a" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "icu_collections", - "icu_properties", - "icu_provider", - "tinystr", - "zerovec", + "either", ] [[package]] @@ -683,9 +756,9 @@ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -708,12 +781,78 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "matrixmultiply" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "ndarray" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "rawpointer", +] + +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "proc-macro2" version = "1.0.69" @@ -732,6 +871,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "regex" version = "1.10.2" @@ -741,7 +886,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.3", - "regex-syntax", + "regex-syntax 0.8.2", ] [[package]] @@ -751,6 +896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9368763f5a9b804326f3af749e16f9abf378d227bcdee7634b13d8f17793782" dependencies = [ "memchr", + "regex-syntax 0.6.29", ] [[package]] @@ -761,9 +907,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.2" @@ -812,18 +964,28 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-aux" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3dfe1b7eb6f9dcf011bd6fad169cdeaae75eda0d61b1a99a3f015b41b0cae39" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -832,9 +994,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -857,19 +1019,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "substring" -version = "1.4.5" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -903,11 +1062,31 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5d0e245e80bdc9b4e5356fc45a72184abbc3861992603f515270e9340f5a219" dependencies = [ + "databake", "displaydoc", "serde", "zerovec", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -1026,6 +1205,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9685bb4deb98dab812e87c296a9631fc00d7ca4bc5c2c5f304f375bbed711a8a" dependencies = [ + "databake", "displaydoc", "litemap", "serde", @@ -1040,6 +1220,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1194130c5b155bf8ae50ab16c86ab758cd695cf9ad176d2f870b744cbdbb572e" dependencies = [ + "databake", "serde", "yoke", "zerofrom", @@ -1056,3 +1237,15 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", + "flate2", +] diff --git a/executors/rust/Cargo.toml b/executors/rust/Cargo.toml index 112f3588..323ddc17 100644 --- a/executors/rust/Cargo.toml +++ b/executors/rust/Cargo.toml @@ -4,31 +4,19 @@ name = "executor" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" -env_logger = "0.9.1" +env_logger = "0.9.1" -substring = "1.0" json = "0.12.4" -serde = {version = "1.0.171", features = ["derive", "alloc"]} +serde = "1.0.171" serde_json = "1.0.100" rustc_version_runtime = "0.1.*" - -fixed_decimal = {version="0.5.3"} -writeable = {version="0.5.2"} -icu_compactdecimal = {version="0.2.0"} -icu_displaynames = {version="0.11.1"} - -icu = {version="1.3.0", features = ["serde"] } -icu_testdata = {version="1.3.0", features = ["icu_compactdecimal", "icu_displaynames"]} -icu_provider = {version="1.3.0", features=["macros"]} -icu_locid = {version="1.3.0"} -icu_locid_transform = {version = "1.3.0", optional=true} -icu_plurals = { version = "1.3.0", optional=true} -icu_decimal = { version = "1.3.0", optional=true} -databake = { version = "0.1.3", features = ["derive"], optional = true} -zerovec = { version = "0.10.0", features = ["yoke"] } - -[features] + +icu = "1.3.0" +icu_compactdecimal = "0.2.0" +icu_displaynames = "0.11.1" +icu_datagen = { version = "1.3.0", default-features = false } + +fixed_decimal ="0.5.3" +writeable ="0.5.2" diff --git a/executors/rust/src/collator.rs b/executors/rust/src/collator.rs index 90119405..019ff148 100644 --- a/executors/rust/src/collator.rs +++ b/executors/rust/src/collator.rs @@ -1,6 +1,4 @@ -/* - * Executor provides tests for Collator. - */ +//! Executor provides tests for Collator. use serde_json::{json, Value}; diff --git a/executors/rust/src/decimalfmt.rs b/executors/rust/src/decimalfmt.rs index bcd47a72..1d345a73 100644 --- a/executors/rust/src/decimalfmt.rs +++ b/executors/rust/src/decimalfmt.rs @@ -1,9 +1,6 @@ -/* - * Executor provides tests for DecimalFormat and NumberFormat. - */ +//! Executor provides tests for DecimalFormat and NumberFormat. use serde_json::{json, Value}; -use writeable::Writeable; use icu::decimal::options; use icu::decimal::FixedDecimalFormatter; @@ -11,7 +8,6 @@ use icu::decimal::FixedDecimalFormatter; use fixed_decimal::FixedDecimal; use icu::locid::locale; -use icu_provider::DataLocale; // Runs decimal and number formatting given patterns or skeletons. pub fn run_numberformat_test(json_obj: &Value) { @@ -25,7 +21,6 @@ pub fn run_numberformat_test(json_obj: &Value) { let locale_name = &json_obj["locale"].as_str().unwrap(); langid = icu::locid:Locale::from_str(&locale_name); } - let data_locale = DataLocale::from(langid); let input = &json_obj["input"].as_str().unwrap(); @@ -35,17 +30,17 @@ pub fn run_numberformat_test(json_obj: &Value) { options.grouping_strategy = options::GroupingStrategy::Min2; let fdf = FixedDecimalFormatter::try_new_with_buffer_provider( - &provider, &data_locale, options) + &provider, &langid.into(), options) .expect("Data should load successfully"); // Check if the conversion from the string input is OK. let input_num: FixedDecimal = input.parse().expect("valid input format"); - let result_string = fdf.format(&input_num); + let result_string = fdf.format_to_string(&input_num); // Result to stdout. let json_result = json!({ "label": label, - "result": result_string.write_to_string()}); + "result": result_string}); print!("{}", json_result); } diff --git a/executors/rust/src/displaynames.rs b/executors/rust/src/displaynames.rs index 8c701591..115975ce 100644 --- a/executors/rust/src/displaynames.rs +++ b/executors/rust/src/displaynames.rs @@ -1,15 +1,12 @@ -/* - * Executor provides tests for DisplayNames. - */ +//! Executor provides tests for DisplayNames. use serde_json::{json, Value}; use std::io::{self, Write}; use core::cmp::Ordering; -use icu::displaynames::*; +use icu::displaynames::*; use icu::locid::{locale, Locale}; -use icu_provider::DataLocale; // Function runs comparison using displaynames pub fn run_coll_test(json_obj: &Value) { @@ -24,14 +21,13 @@ pub fn run_coll_test(json_obj: &Value) { } else { locale!("und") }; - let data_locale = DataLocale::from(langid); let data_provider = icu_testdata::unstable(); let mut options = DisplayNamesOptions::new(); let displaynames: DisplayNames = - DisplayNames::try_new_unstable(&data_provider, data_locale, options).unwrap(); + DisplayNames::try_new_unstable(&data_provider, langid.into(), options).unwrap(); let result = displaynames.of(input); diff --git a/executors/rust/src/langnames.rs b/executors/rust/src/langnames.rs index 50c3eebb..6d66fcc2 100644 --- a/executors/rust/src/langnames.rs +++ b/executors/rust/src/langnames.rs @@ -1,6 +1,4 @@ -/* - * Executor provides tests for LanguageNames, a special case of DisplayNames. - */ +//! Executor provides tests for LanguageNames, a special case of DisplayNames. use serde_json::{json, Value}; @@ -9,10 +7,6 @@ use icu_displaynames::{DisplayNamesOptions, LanguageDisplayNames}; use icu::locid::subtags::Language; use icu::locid::Locale; -use icu_provider::DataLocale; - -use std::str::FromStr; - // Function runs language names tests pub fn run_language_name_test(json_obj: &Value) -> Result { let label = &json_obj["label"].as_str().unwrap(); @@ -22,7 +16,7 @@ pub fn run_language_name_test(json_obj: &Value) -> Result { .as_str() .unwrap() .replace('_', "-"); - let input_lang_result = Language::from_str(&language_label); + let input_lang_result = language_label.parse::(); let input_lang = match input_lang_result { Ok(l) => l, Err(_e) => { @@ -55,7 +49,7 @@ pub fn run_language_name_test(json_obj: &Value) -> Result { } }; - let langid_result = Locale::from_str(locale_name); + let langid_result = locale_name.parse::(); let langid = match langid_result { Ok(lid) => lid, @@ -73,10 +67,7 @@ pub fn run_language_name_test(json_obj: &Value) -> Result { } }; - // The locale data may not yet be supported. - let data_locale = DataLocale::from(&langid); - - let display_name_formatter = LanguageDisplayNames::try_new(&data_locale, options); + let display_name_formatter = LanguageDisplayNames::try_new(&langid.into(), options); let json_result = match display_name_formatter { Ok(formatter) => { diff --git a/executors/rust/src/likelysubtags.rs b/executors/rust/src/likelysubtags.rs index eb5be86c..559e614f 100644 --- a/executors/rust/src/likelysubtags.rs +++ b/executors/rust/src/likelysubtags.rs @@ -1,15 +1,11 @@ -/* - * Provides tests for likely subtags to mimimize and maximize. - */ +//! Provides tests for likely subtags to mimimize and maximize. use serde_json::{json, Value}; use icu::locid::Locale; use icu::locid_transform::LocaleExpander; -use std::str::FromStr; - -// https://docs.rs/icu_locid_transform/latest/icu_locid_transform/ +// https://docs.rs/icu/latest/icu/locid_transform/ // Function runs language names tests pub fn run_likelysubtags_test(json_obj: &Value) -> Result { @@ -21,7 +17,7 @@ pub fn run_likelysubtags_test(json_obj: &Value) -> Result { let locale_str: &str = json_obj["locale"].as_str().unwrap(); - let mut locale = Locale::from_str(locale_str).unwrap(); + let mut locale = locale_str.parse::().unwrap(); if test_option == &"minimizeFavorRegion" { // This option is not yet supported. diff --git a/executors/rust/src/main.rs b/executors/rust/src/main.rs index 421f19ce..c8e9dd7d 100644 --- a/executors/rust/src/main.rs +++ b/executors/rust/src/main.rs @@ -28,8 +28,6 @@ use std::collections::HashMap; use std::env; use std::io::{self}; -use substring::Substring; - // Test modules for each type use collator::run_collation_test; use langnames::run_language_name_test; @@ -60,10 +58,10 @@ fn main() -> io::Result<()> { if buffer_size == 0 { break; } - if buffer.substring(0, 5) == "#EXIT" { + if buffer.starts_with("#EXIT") { break; } - if buffer.substring(0, 6) == "#TESTS" { + if buffer.starts_with("#TESTS") { // Returns JSON list of supported tests. // TODO: let mut test_vec : Vec<&str> = supported_test_map.into_keys().collect(); let json_result = json!( @@ -76,15 +74,13 @@ fn main() -> io::Result<()> { println!("{}", json_result); } - if buffer.substring(0, 8) == "#VERSION" { + if buffer.starts_with("#VERSION") { // Get data version information from PackageMetadata // https://crates.io/crates/rustc_version_runtime // https://github.com/serde-rs/json - #[allow(deprecated)] // this function only exists in icu_testdata - let icu_version = &icu_testdata::versions::icu_tag(); - #[allow(deprecated)] - let cldr_version = &icu_testdata::versions::cldr_tag(); + let icu_version = icu_datagen::DatagenProvider::LATEST_TESTED_ICUEXPORT_TAG; + let cldr_version = icu_datagen::DatagenProvider::LATEST_TESTED_CLDR_TAG; let json_result = json!( { diff --git a/executors/rust/src/numberfmt.rs b/executors/rust/src/numberfmt.rs index d0e4f81c..045c674d 100644 --- a/executors/rust/src/numberfmt.rs +++ b/executors/rust/src/numberfmt.rs @@ -1,6 +1,4 @@ -/* - * Executor provides tests for NumberFormat and DecimalFormat. - */ +//! Executor provides tests for NumberFormat and DecimalFormat. use fixed_decimal::FixedDecimal; use fixed_decimal::SignDisplay; @@ -11,15 +9,11 @@ use icu::decimal::FixedDecimalFormatter; use icu_compactdecimal::CompactDecimalFormatter; -use icu::locid::{locale, Locale}; -use icu_provider::DataLocale; +use icu::locid::{extensions::unicode::key, locale, Locale}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use std::panic; -use std::str::FromStr; - use writeable::Writeable; // Support options - update when ICU4X adds support @@ -62,13 +56,12 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { let label = &json_obj["label"].as_str().unwrap(); // Default locale if not specified. - let langid = if json_obj.get("locale").is_some() { + let mut langid = if json_obj.get("locale").is_some() { let locale_name = &json_obj["locale"].as_str().unwrap(); - Locale::from_str(locale_name).unwrap() + locale_name.parse::().unwrap() } else { locale!("und") }; - let mut data_locale = DataLocale::from(langid); let input = &json_obj["input"].as_str().unwrap(); @@ -90,19 +83,19 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { is_compact = true; } if option_struct.compact_display.is_some() { - compact_type = &option_struct.compact_display.as_ref().unwrap(); + compact_type = option_struct.compact_display.as_ref().unwrap(); } if option_struct.notation == Some(String::from("scientific")) { is_scientific = true; } if option_struct.style.is_some() { - style = &option_struct.style.as_ref().unwrap(); + style = option_struct.style.as_ref().unwrap(); } if option_struct.unit.is_some() { - unit = &option_struct.unit.as_ref().unwrap(); + unit = option_struct.unit.as_ref().unwrap(); } if option_struct.rounding_mode.is_some() { - _rounding_mode = &option_struct.rounding_mode.as_ref().unwrap(); + _rounding_mode = option_struct.rounding_mode.as_ref().unwrap(); } let mut options: options::FixedDecimalFormatterOptions = Default::default(); // TODO: Use options to call operations including pad and trunc with rounding. @@ -146,7 +139,11 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { // -------------------------------------------------------------------------------- if let Some(numsys) = option_struct.numbering_system.as_ref() { - data_locale.set_unicode_ext("nu".parse().unwrap(), numsys.parse().unwrap()); + langid + .extensions + .unicode + .keywords + .set(key!("nu"), numsys.parse().unwrap()); } // Returns error if parsing the number string fails. @@ -155,19 +152,16 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { let result_string = if is_compact { // We saw compact! let cdf = if compact_type == "short" { - CompactDecimalFormatter::try_new_short(&data_locale, Default::default()).unwrap() + CompactDecimalFormatter::try_new_short(&langid.into(), Default::default()).unwrap() } else { println!("#{:?}", " LONG"); - CompactDecimalFormatter::try_new_long(&data_locale, Default::default()).unwrap() + CompactDecimalFormatter::try_new_long(&langid.into(), Default::default()).unwrap() }; // input.parse().map_err(|e| e.to_string())?; - let input_num = FixedDecimal::from_str(input).map_err(|e| e.to_string())?; + let input_num = input.parse::().map_err(|e| e.to_string())?; let formatted_cdf = cdf.format_fixed_decimal(input_num); - formatted_cdf - //.map_err(|e| e.to_string())? - .write_to_string() - .into_owned() + formatted_cdf.write_to_string().into_owned() // } // else if is_scientific { // let mut sci_decimal = input.parse::().map_err(|e| e.to_string()); @@ -175,7 +169,7 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { } else { // FixedDecimal // Can this fail with invalid options? - let fdf = FixedDecimalFormatter::try_new(&data_locale, options.clone()) + let fdf = FixedDecimalFormatter::try_new(&langid.into(), options.clone()) .expect("Data should load successfully"); // Apply relevant options for digits. @@ -218,7 +212,7 @@ pub fn run_numberformat_test(json_obj: &Value) -> Result { } // Apply the options and get formatted string. - fdf.format(&input_num).write_to_string().into_owned() + fdf.format_to_string(&input_num) }; // Result to stdout.