summaryrefslogtreecommitdiff
path: root/vendor/tinystr
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-10 13:11:11 -0600
committermo khan <mo@mokhan.ca>2025-07-10 13:11:11 -0600
commit01959b16a21b22b5df5f16569c2a8e8f92beecef (patch)
tree32afa5d747c5466345c59ec52161a7cba3d6d755 /vendor/tinystr
parentff30574117a996df332e23d1fb6f65259b316b5b (diff)
chore: vendor dependencies
Diffstat (limited to 'vendor/tinystr')
-rw-r--r--vendor/tinystr/.cargo-checksum.json1
-rw-r--r--vendor/tinystr/Cargo.lock772
-rw-r--r--vendor/tinystr/Cargo.toml129
-rw-r--r--vendor/tinystr/LICENSE46
-rw-r--r--vendor/tinystr/README.md57
-rw-r--r--vendor/tinystr/benches/common/mod.rs55
-rw-r--r--vendor/tinystr/benches/construct.rs65
-rw-r--r--vendor/tinystr/benches/overview.rs129
-rw-r--r--vendor/tinystr/benches/read.rs34
-rw-r--r--vendor/tinystr/benches/serde.rs37
-rw-r--r--vendor/tinystr/src/ascii.rs1175
-rw-r--r--vendor/tinystr/src/asciibyte.rs145
-rw-r--r--vendor/tinystr/src/databake.rs75
-rw-r--r--vendor/tinystr/src/error.rs18
-rw-r--r--vendor/tinystr/src/int_ops.rs315
-rw-r--r--vendor/tinystr/src/lib.rs114
-rw-r--r--vendor/tinystr/src/macros.rs32
-rw-r--r--vendor/tinystr/src/serde.rs91
-rw-r--r--vendor/tinystr/src/ule.rs125
-rw-r--r--vendor/tinystr/src/unvalidated.rs122
-rw-r--r--vendor/tinystr/tests/serde.rs39
21 files changed, 3576 insertions, 0 deletions
diff --git a/vendor/tinystr/.cargo-checksum.json b/vendor/tinystr/.cargo-checksum.json
new file mode 100644
index 00000000..6173ed6f
--- /dev/null
+++ b/vendor/tinystr/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.lock":"6e22a89a3ef2eb86626e7ee07356dd4b6904a26880e0ef09926358ac209f75d9","Cargo.toml":"3d9722213fe432999bc943056f9c51eefa21023b6b069122ae7e3890a4d0e76f","LICENSE":"f367c1b8e1aa262435251e442901da4607b4650e0e63a026f5044473ecfb90f2","README.md":"b7b7a33a29865bc653a6696b079c1527ba61cd58a815fc792ed6fa5bfc680ad5","benches/common/mod.rs":"7e709fcabc2f96b10d3db8968ef3ea7fcc25e88211ce97b64b2126c7a0d7387a","benches/construct.rs":"718c4207e07091d8c16e78824f1850dbb218a02e10300117036742a6e52d2f61","benches/overview.rs":"3e5cb89dccff91ce8d53e36a6db8e548a07dd440bc6b79fb53c7b1734512dd1b","benches/read.rs":"cbf349393a50eb90e7ba53906f98a689d585242292f867a37acf6842263af4d9","benches/serde.rs":"5c88866d08c07088b82dbd5472e6276c632d11e064417f5d8f2025a5ade867f0","src/ascii.rs":"0edd0e37be444363806d571c642001c15693f5d5b76a7fb2579533993fb5d2b5","src/asciibyte.rs":"fa29de7403c0424c52c2f30bb47002b9abf4bd08b302c411ffe679d3decfb8de","src/databake.rs":"86d4ee8fd748a2a78dfd4ca4cfc7c3b5abdaee8c0a40f582a234793af4c459fe","src/error.rs":"69719fd65981c5f6ac633da60a075bbbd98a02f60e10db48f9dc626ed9b6e498","src/int_ops.rs":"0687e550ff1386aa0bfb936de8344b4161622d346c18abb332ccce4163c03183","src/lib.rs":"f453563c4415f8598c287bd938d450d7326ee03c99e9276316308a3b22edba62","src/macros.rs":"c6fe247da7a7477dab2549727fca78d7476167b383628b0876fe8e3d71165507","src/serde.rs":"d45712df0dd81a7c9e07cb57d445b1d746192db90c954159aeeb59bef4ce85a0","src/ule.rs":"193b183c34269e2c6c0438c2f5e2a89edec441a7b8f5bc465f3a3b8d52af1ca8","src/unvalidated.rs":"7887cf36d4d8ed87f8352ebe188bcd1ddd89f26818a97a212eee12718c810db9","tests/serde.rs":"cf8cee82f731928375888d1b5e7e5e50368d3e16ce372fced230c9b1ee2a7451"},"package":"5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"} \ No newline at end of file
diff --git a/vendor/tinystr/Cargo.lock b/vendor/tinystr/Cargo.lock
new file mode 100644
index 00000000..1a8c4da2
--- /dev/null
+++ b/vendor/tinystr/Cargo.lock
@@ -0,0 +1,772 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anes"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
+
+[[package]]
+name = "anstyle"
+version = "1.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
+[[package]]
+name = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
+
+[[package]]
+name = "byteorder"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+[[package]]
+name = "cast"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "ciborium"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
+dependencies = [
+ "ciborium-io",
+ "ciborium-ll",
+ "serde",
+]
+
+[[package]]
+name = "ciborium-io"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
+
+[[package]]
+name = "ciborium-ll"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
+dependencies = [
+ "ciborium-io",
+ "half",
+]
+
+[[package]]
+name = "clap"
+version = "4.5.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767"
+dependencies = [
+ "clap_builder",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.5.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863"
+dependencies = [
+ "anstyle",
+ "clap_lex",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
+
+[[package]]
+name = "cobs"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
+
+[[package]]
+name = "criterion"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
+dependencies = [
+ "anes",
+ "cast",
+ "ciborium",
+ "clap",
+ "criterion-plot",
+ "is-terminal",
+ "itertools",
+ "num-traits",
+ "once_cell",
+ "oorandom",
+ "plotters",
+ "rayon",
+ "regex",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "tinytemplate",
+ "walkdir",
+]
+
+[[package]]
+name = "criterion-plot"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
+dependencies = [
+ "cast",
+ "itertools",
+]
+
+[[package]]
+name = "crossbeam-deque"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
+dependencies = [
+ "crossbeam-epoch",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-epoch"
+version = "0.9.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
+
+[[package]]
+name = "crunchy"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
+
+[[package]]
+name = "databake"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff6ee9e2d2afb173bcdeee45934c89ec341ab26f91c9933774fc15c2b58f83ef"
+dependencies = [
+ "proc-macro2",
+ "quote",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "either"
+version = "1.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d"
+
+[[package]]
+name = "embedded-io"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
+
+[[package]]
+name = "embedded-io"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
+
+[[package]]
+name = "getrandom"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "half"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
+
+[[package]]
+name = "is-terminal"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "itertools"
+version = "0.10.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
+
+[[package]]
+name = "js-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
+dependencies = [
+ "once_cell",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.170"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
+
+[[package]]
+name = "log"
+version = "0.4.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
+
+[[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
+
+[[package]]
+name = "oorandom"
+version = "11.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
+
+[[package]]
+name = "plotters"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
+dependencies = [
+ "num-traits",
+ "plotters-backend",
+ "plotters-svg",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "plotters-backend"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
+
+[[package]]
+name = "plotters-svg"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670"
+dependencies = [
+ "plotters-backend",
+]
+
+[[package]]
+name = "postcard"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
+dependencies = [
+ "cobs",
+ "embedded-io 0.4.0",
+ "embedded-io 0.6.1",
+ "serde",
+]
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
+dependencies = [
+ "zerocopy",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "rayon"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
+dependencies = [
+ "either",
+ "rayon-core",
+]
+
+[[package]]
+name = "rayon-core"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
+dependencies = [
+ "crossbeam-deque",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "regex"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+
+[[package]]
+name = "rustversion"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
+
+[[package]]
+name = "ryu"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.218"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.218"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.139"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.98"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.1"
+dependencies = [
+ "bincode",
+ "criterion",
+ "databake",
+ "displaydoc",
+ "postcard",
+ "rand",
+ "serde",
+ "serde_json",
+ "zerovec",
+]
+
+[[package]]
+name = "tinytemplate"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
+dependencies = [
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
+
+[[package]]
+name = "walkdir"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
+dependencies = [
+ "bumpalo",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "winapi-util"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "zerocopy"
+version = "0.7.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
+dependencies = [
+ "byteorder",
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
+
+[[package]]
+name = "zerovec"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94e62113720e311984f461c56b00457ae9981c0bc7859d22306cc2ae2f95571c"
+dependencies = [
+ "zerofrom",
+]
diff --git a/vendor/tinystr/Cargo.toml b/vendor/tinystr/Cargo.toml
new file mode 100644
index 00000000..a44b5bd9
--- /dev/null
+++ b/vendor/tinystr/Cargo.toml
@@ -0,0 +1,129 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2021"
+rust-version = "1.81"
+name = "tinystr"
+version = "0.8.1"
+authors = ["The ICU4X Project Developers"]
+build = false
+include = [
+ "data/**/*",
+ "src/**/*",
+ "examples/**/*",
+ "benches/**/*",
+ "tests/**/*",
+ "Cargo.toml",
+ "LICENSE",
+ "README.md",
+]
+autolib = false
+autobins = false
+autoexamples = false
+autotests = false
+autobenches = false
+description = "A small ASCII-only bounded length string representation."
+readme = "README.md"
+keywords = [
+ "string",
+ "str",
+ "small",
+ "tiny",
+ "no_std",
+]
+categories = ["data-structures"]
+license = "Unicode-3.0"
+repository = "https://github.com/unicode-org/icu4x"
+
+[package.metadata.docs.rs]
+all-features = true
+
+[package.metadata.workspaces]
+independent = true
+
+[features]
+alloc = ["zerovec?/alloc"]
+databake = ["dep:databake"]
+default = ["alloc"]
+serde = ["dep:serde"]
+std = []
+zerovec = ["dep:zerovec"]
+
+[lib]
+name = "tinystr"
+path = "src/lib.rs"
+bench = false
+
+[[test]]
+name = "serde"
+path = "tests/serde.rs"
+required-features = ["serde"]
+
+[[bench]]
+name = "construct"
+path = "benches/construct.rs"
+harness = false
+
+[[bench]]
+name = "overview"
+path = "benches/overview.rs"
+harness = false
+
+[[bench]]
+name = "read"
+path = "benches/read.rs"
+harness = false
+
+[[bench]]
+name = "serde"
+path = "benches/serde.rs"
+harness = false
+required-features = ["serde"]
+
+[dependencies.databake]
+version = "0.2.0"
+optional = true
+default-features = false
+
+[dependencies.displaydoc]
+version = "0.2.3"
+default-features = false
+
+[dependencies.serde]
+version = "1.0.110"
+features = ["alloc"]
+optional = true
+default-features = false
+
+[dependencies.zerovec]
+version = "0.11.1"
+optional = true
+default-features = false
+
+[dev-dependencies.bincode]
+version = "1.3.1"
+
+[dev-dependencies.postcard]
+version = "1.0.3"
+features = ["use-std"]
+default-features = false
+
+[dev-dependencies.rand]
+version = "0.8"
+features = ["small_rng"]
+
+[dev-dependencies.serde_json]
+version = "1.0.45"
+features = ["alloc"]
+
+[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.criterion]
+version = "0.5.0"
diff --git a/vendor/tinystr/LICENSE b/vendor/tinystr/LICENSE
new file mode 100644
index 00000000..c9be6012
--- /dev/null
+++ b/vendor/tinystr/LICENSE
@@ -0,0 +1,46 @@
+UNICODE LICENSE V3
+
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright © 2020-2024 Unicode, Inc.
+
+NOTICE TO USER: Carefully read the following legal agreement. BY
+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
+SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
+TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
+DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of data files and any associated documentation (the "Data Files") or
+software and any associated documentation (the "Software") to deal in the
+Data Files or Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, and/or sell
+copies of the Data Files or Software, and to permit persons to whom the
+Data Files or Software are furnished to do so, provided that either (a)
+this copyright and permission notice appear with all copies of the Data
+Files or Software, or (b) this copyright and permission notice appear in
+associated Documentation.
+
+THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+THIRD PARTY RIGHTS.
+
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
+BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
+OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
+FILES OR SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in these Data Files or Software without prior written
+authorization of the copyright holder.
+
+SPDX-License-Identifier: Unicode-3.0
+
+—
+
+Portions of ICU4X may have been adapted from ICU4C and/or ICU4J.
+ICU 1.8.1 to ICU 57.1 © 1995-2016 International Business Machines Corporation and others.
diff --git a/vendor/tinystr/README.md b/vendor/tinystr/README.md
new file mode 100644
index 00000000..92b74c0d
--- /dev/null
+++ b/vendor/tinystr/README.md
@@ -0,0 +1,57 @@
+# tinystr [![crates.io](https://img.shields.io/crates/v/tinystr)](https://crates.io/crates/tinystr)
+
+<!-- cargo-rdme start -->
+
+`tinystr` is a utility crate of the [`ICU4X`] project.
+
+It includes [`TinyAsciiStr`], a core API for representing small ASCII-only bounded length strings.
+
+It is optimized for operations on strings of size 8 or smaller. When use cases involve comparison
+and conversion of strings for lowercase/uppercase/titlecase, or checking
+numeric/alphabetic/alphanumeric, `TinyAsciiStr` is the edge performance library.
+
+## Examples
+
+```rust
+use tinystr::TinyAsciiStr;
+
+let s1: TinyAsciiStr<4> = "tEsT".parse().expect("Failed to parse.");
+
+assert_eq!(s1, "tEsT");
+assert_eq!(s1.to_ascii_uppercase(), "TEST");
+assert_eq!(s1.to_ascii_lowercase(), "test");
+assert_eq!(s1.to_ascii_titlecase(), "Test");
+assert!(s1.is_ascii_alphanumeric());
+assert!(!s1.is_ascii_numeric());
+
+let s2 = TinyAsciiStr::<8>::try_from_raw(*b"New York")
+ .expect("Failed to parse.");
+
+assert_eq!(s2, "New York");
+assert_eq!(s2.to_ascii_uppercase(), "NEW YORK");
+assert_eq!(s2.to_ascii_lowercase(), "new york");
+assert_eq!(s2.to_ascii_titlecase(), "New york");
+assert!(!s2.is_ascii_alphanumeric());
+```
+
+## Details
+
+When strings are of size 8 or smaller, the struct transforms the strings as `u32`/`u64` and uses
+bitmasking to provide basic string manipulation operations:
+* `is_ascii_numeric`
+* `is_ascii_alphabetic`
+* `is_ascii_alphanumeric`
+* `to_ascii_lowercase`
+* `to_ascii_uppercase`
+* `to_ascii_titlecase`
+* `PartialEq`
+
+`TinyAsciiStr` will fall back to `u8` character manipulation for strings of length greater than 8.
+
+[`ICU4X`]: ../icu/index.html
+
+<!-- cargo-rdme end -->
+
+## More Information
+
+For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
diff --git a/vendor/tinystr/benches/common/mod.rs b/vendor/tinystr/benches/common/mod.rs
new file mode 100644
index 00000000..84090b6c
--- /dev/null
+++ b/vendor/tinystr/benches/common/mod.rs
@@ -0,0 +1,55 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+// This file was adapted from parts of https://github.com/zbraniecki/tinystr
+
+pub static STRINGS_4: &[&str] = &[
+ "US", "GB", "AR", "Hans", "CN", "AT", "PL", "FR", "AT", "Cyrl", "SR", "NO", "FR", "MK", "UK",
+];
+
+pub static STRINGS_8: &[&str] = &[
+ "Latn", "windows", "AR", "Hans", "macos", "AT", "pl", "FR", "en", "Cyrl", "SR", "NO", "419",
+ "und", "UK",
+];
+
+pub static STRINGS_16: &[&str] = &[
+ "Latn",
+ "windows",
+ "AR",
+ "Hans",
+ "macos",
+ "AT",
+ "infiniband",
+ "FR",
+ "en",
+ "Cyrl",
+ "FromIntegral",
+ "NO",
+ "419",
+ "MacintoshOSX2019",
+ "UK",
+];
+
+#[macro_export]
+macro_rules! bench_block {
+ ($c:expr, $name:expr, $action:ident) => {
+ let mut group4 = $c.benchmark_group(&format!("{}/4", $name));
+ group4.bench_function("String", $action!(String, STRINGS_4));
+ group4.bench_function("TinyAsciiStr<4>", $action!(TinyAsciiStr<4>, STRINGS_4));
+ group4.bench_function("TinyAsciiStr<8>", $action!(TinyAsciiStr<8>, STRINGS_4));
+ group4.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_4));
+ group4.finish();
+
+ let mut group8 = $c.benchmark_group(&format!("{}/8", $name));
+ group8.bench_function("String", $action!(String, STRINGS_8));
+ group8.bench_function("TinyAsciiStr<8>", $action!(TinyAsciiStr<8>, STRINGS_8));
+ group8.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_8));
+ group8.finish();
+
+ let mut group16 = $c.benchmark_group(&format!("{}/16", $name));
+ group16.bench_function("String", $action!(String, STRINGS_16));
+ group16.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_16));
+ group16.finish();
+ };
+}
diff --git a/vendor/tinystr/benches/construct.rs b/vendor/tinystr/benches/construct.rs
new file mode 100644
index 00000000..09180298
--- /dev/null
+++ b/vendor/tinystr/benches/construct.rs
@@ -0,0 +1,65 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+// This file was adapted from https://github.com/zbraniecki/tinystr
+
+mod common;
+use common::*;
+
+use criterion::black_box;
+use criterion::criterion_group;
+use criterion::criterion_main;
+use criterion::Bencher;
+use criterion::Criterion;
+
+use tinystr::TinyAsciiStr;
+
+fn construct_from_str(c: &mut Criterion) {
+ macro_rules! cfs {
+ ($r:ty, $inputs:expr) => {
+ |b: &mut Bencher| {
+ b.iter(|| {
+ for s in $inputs {
+ let _: $r = black_box(s.parse().unwrap());
+ }
+ })
+ }
+ };
+ }
+
+ bench_block!(c, "construct_from_str", cfs);
+}
+
+fn construct_from_utf8(c: &mut Criterion) {
+ macro_rules! cfu {
+ ($r:ty, $inputs:expr) => {
+ |b| {
+ let raw: Vec<&[u8]> = $inputs.iter().map(|s| s.as_bytes()).collect();
+ b.iter(move || {
+ for u in &raw {
+ let _ = black_box(<$r>::try_from_utf8(*u).unwrap());
+ }
+ })
+ }
+ };
+ }
+
+ let mut group4 = c.benchmark_group("construct_from_utf8/4");
+ group4.bench_function("TinyAsciiStr<4>", cfu!(TinyAsciiStr<4>, STRINGS_4));
+ group4.bench_function("TinyAsciiStr<8>", cfu!(TinyAsciiStr<8>, STRINGS_4));
+ group4.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_4));
+ group4.finish();
+
+ let mut group8 = c.benchmark_group("construct_from_utf8/8");
+ group8.bench_function("TinyAsciiStr<8>", cfu!(TinyAsciiStr<8>, STRINGS_8));
+ group8.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_8));
+ group8.finish();
+
+ let mut group16 = c.benchmark_group("construct_from_utf8/16");
+ group16.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_16));
+ group16.finish();
+}
+
+criterion_group!(benches, construct_from_str, construct_from_utf8,);
+criterion_main!(benches);
diff --git a/vendor/tinystr/benches/overview.rs b/vendor/tinystr/benches/overview.rs
new file mode 100644
index 00000000..474ff4b9
--- /dev/null
+++ b/vendor/tinystr/benches/overview.rs
@@ -0,0 +1,129 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+mod common;
+use common::*;
+
+use criterion::black_box;
+use criterion::criterion_group;
+use criterion::criterion_main;
+use criterion::Criterion;
+
+use tinystr::TinyAsciiStr;
+
+fn overview(c: &mut Criterion) {
+ let mut g = c.benchmark_group("overview");
+
+ g.bench_function("construct/utf8/TinyAsciiStr", |b| {
+ b.iter(|| {
+ for s in STRINGS_4 {
+ let _: TinyAsciiStr<4> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ let _: TinyAsciiStr<8> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ let _: TinyAsciiStr<16> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ }
+ for s in STRINGS_8 {
+ let _: TinyAsciiStr<8> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ let _: TinyAsciiStr<16> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ }
+ for s in STRINGS_16 {
+ let _: TinyAsciiStr<16> =
+ TinyAsciiStr::try_from_utf8(black_box(s.as_bytes())).unwrap();
+ }
+ });
+ });
+
+ let strings_4_utf16: Vec<Vec<u16>> = STRINGS_4
+ .iter()
+ .map(|s| s.encode_utf16().collect())
+ .collect();
+
+ let strings_8_utf16: Vec<Vec<u16>> = STRINGS_8
+ .iter()
+ .map(|s| s.encode_utf16().collect())
+ .collect();
+
+ let strings_16_utf16: Vec<Vec<u16>> = STRINGS_16
+ .iter()
+ .map(|s| s.encode_utf16().collect())
+ .collect();
+
+ g.bench_function("construct/utf16/TinyAsciiStr", |b| {
+ b.iter(|| {
+ for s in strings_4_utf16.iter() {
+ let _: TinyAsciiStr<4> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ let _: TinyAsciiStr<8> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ let _: TinyAsciiStr<16> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ }
+ for s in strings_8_utf16.iter() {
+ let _: TinyAsciiStr<8> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ let _: TinyAsciiStr<16> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ }
+ for s in strings_16_utf16.iter() {
+ let _: TinyAsciiStr<16> = TinyAsciiStr::try_from_utf16(black_box(s)).unwrap();
+ }
+ });
+ });
+
+ let parsed_ascii_4: Vec<TinyAsciiStr<4>> = STRINGS_4
+ .iter()
+ .map(|s| s.parse::<TinyAsciiStr<4>>().unwrap())
+ .collect();
+ let parsed_ascii_8: Vec<TinyAsciiStr<8>> = STRINGS_4
+ .iter()
+ .chain(STRINGS_8)
+ .map(|s| s.parse::<TinyAsciiStr<8>>().unwrap())
+ .collect();
+ let parsed_ascii_16: Vec<TinyAsciiStr<16>> = STRINGS_4
+ .iter()
+ .chain(STRINGS_8)
+ .chain(STRINGS_16)
+ .map(|s| s.parse::<TinyAsciiStr<16>>().unwrap())
+ .collect();
+
+ g.bench_function("read/TinyAsciiStr", |b| {
+ b.iter(|| {
+ let mut collector: usize = 0;
+ for t in black_box(&parsed_ascii_4) {
+ let s: &str = t;
+ collector += s.bytes().map(usize::from).sum::<usize>();
+ }
+ for t in black_box(&parsed_ascii_8) {
+ let s: &str = t;
+ collector += s.bytes().map(usize::from).sum::<usize>();
+ }
+ for t in black_box(&parsed_ascii_16) {
+ let s: &str = t;
+ collector += s.bytes().map(usize::from).sum::<usize>();
+ }
+ collector
+ });
+ });
+
+ g.bench_function("compare/TinyAsciiStr", |b| {
+ b.iter(|| {
+ let mut collector: usize = 0;
+ for ts in black_box(&parsed_ascii_4).windows(2) {
+ let o = ts[0].cmp(&ts[1]);
+ collector ^= o as usize;
+ }
+ for ts in black_box(&parsed_ascii_8).windows(2) {
+ let o = ts[0].cmp(&ts[1]);
+ collector ^= o as usize;
+ }
+ for ts in black_box(&parsed_ascii_16).windows(2) {
+ let o = ts[0].cmp(&ts[1]);
+ collector ^= o as usize;
+ }
+ collector
+ });
+ });
+}
+
+criterion_group!(benches, overview,);
+criterion_main!(benches);
diff --git a/vendor/tinystr/benches/read.rs b/vendor/tinystr/benches/read.rs
new file mode 100644
index 00000000..793bb14f
--- /dev/null
+++ b/vendor/tinystr/benches/read.rs
@@ -0,0 +1,34 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+mod common;
+use common::*;
+
+use criterion::black_box;
+use criterion::criterion_group;
+use criterion::criterion_main;
+use criterion::Bencher;
+use criterion::Criterion;
+
+use tinystr::TinyAsciiStr;
+
+fn read(c: &mut Criterion) {
+ macro_rules! cfs {
+ ($r:ty, $inputs:expr) => {
+ |b: &mut Bencher| {
+ let parsed: Vec<$r> = $inputs.iter().map(|s| s.parse().unwrap()).collect();
+ b.iter(|| {
+ for s in &parsed {
+ let _: &str = black_box(&**s);
+ }
+ })
+ }
+ };
+ }
+
+ bench_block!(c, "read", cfs);
+}
+
+criterion_group!(benches, read,);
+criterion_main!(benches);
diff --git a/vendor/tinystr/benches/serde.rs b/vendor/tinystr/benches/serde.rs
new file mode 100644
index 00000000..b0341221
--- /dev/null
+++ b/vendor/tinystr/benches/serde.rs
@@ -0,0 +1,37 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+mod common;
+use common::*;
+
+use criterion::black_box;
+use criterion::criterion_group;
+use criterion::criterion_main;
+use criterion::Bencher;
+use criterion::Criterion;
+
+use tinystr::TinyAsciiStr;
+
+fn deserialize(c: &mut Criterion) {
+ macro_rules! cfs {
+ ($r:ty, $inputs:expr) => {
+ |b: &mut Bencher| {
+ let serialized: Vec<Vec<u8>> = $inputs
+ .iter()
+ .map(|s| postcard::to_stdvec(&s.parse::<$r>().unwrap()).unwrap())
+ .collect();
+ b.iter(|| {
+ for bytes in &serialized {
+ let _: Result<$r, _> = black_box(postcard::from_bytes(bytes));
+ }
+ })
+ }
+ };
+ }
+
+ bench_block!(c, "deserialize", cfs);
+}
+
+criterion_group!(benches, deserialize,);
+criterion_main!(benches);
diff --git a/vendor/tinystr/src/ascii.rs b/vendor/tinystr/src/ascii.rs
new file mode 100644
index 00000000..89ec742b
--- /dev/null
+++ b/vendor/tinystr/src/ascii.rs
@@ -0,0 +1,1175 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::asciibyte::AsciiByte;
+use crate::int_ops::{Aligned4, Aligned8};
+use crate::ParseError;
+use core::borrow::Borrow;
+use core::fmt;
+use core::ops::Deref;
+use core::str::{self, FromStr};
+
+#[repr(transparent)]
+#[derive(PartialEq, Eq, Ord, PartialOrd, Copy, Clone, Hash)]
+pub struct TinyAsciiStr<const N: usize> {
+ bytes: [AsciiByte; N],
+}
+
+impl<const N: usize> TinyAsciiStr<N> {
+ #[inline]
+ pub const fn try_from_str(s: &str) -> Result<Self, ParseError> {
+ Self::try_from_utf8(s.as_bytes())
+ }
+
+ /// Creates a `TinyAsciiStr<N>` from the given UTF-8 slice.
+ /// `code_units` may contain at most `N` non-null ASCII code points.
+ #[inline]
+ pub const fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError> {
+ Self::try_from_utf8_inner(code_units, false)
+ }
+
+ /// Creates a `TinyAsciiStr<N>` from the given UTF-16 slice.
+ /// `code_units` may contain at most `N` non-null ASCII code points.
+ #[inline]
+ pub const fn try_from_utf16(code_units: &[u16]) -> Result<Self, ParseError> {
+ Self::try_from_utf16_inner(code_units, 0, code_units.len(), false)
+ }
+
+ /// Creates a `TinyAsciiStr<N>` from a UTF-8 slice, replacing invalid code units.
+ ///
+ /// Invalid code units, as well as null or non-ASCII code points
+ /// (i.e. those outside the range U+0001..=U+007F`)
+ /// will be replaced with the replacement byte.
+ ///
+ /// The input slice will be truncated if its length exceeds `N`.
+ pub const fn from_utf8_lossy(code_units: &[u8], replacement: u8) -> Self {
+ let mut out = [0; N];
+ let mut i = 0;
+ // Ord is not available in const, so no `.min(N)`
+ let len = if code_units.len() > N {
+ N
+ } else {
+ code_units.len()
+ };
+
+ // Indexing is protected by the len check above
+ #[allow(clippy::indexing_slicing)]
+ while i < len {
+ let b = code_units[i];
+ if b > 0 && b < 0x80 {
+ out[i] = b;
+ } else {
+ out[i] = replacement;
+ }
+ i += 1;
+ }
+
+ Self {
+ // SAFETY: `out` only contains ASCII bytes and has same size as `self.bytes`
+ bytes: unsafe { AsciiByte::to_ascii_byte_array(&out) },
+ }
+ }
+
+ /// Creates a `TinyAsciiStr<N>` from a UTF-16 slice, replacing invalid code units.
+ ///
+ /// Invalid code units, as well as null or non-ASCII code points
+ /// (i.e. those outside the range U+0001..=U+007F`)
+ /// will be replaced with the replacement byte.
+ ///
+ /// The input slice will be truncated if its length exceeds `N`.
+ pub const fn from_utf16_lossy(code_units: &[u16], replacement: u8) -> Self {
+ let mut out = [0; N];
+ let mut i = 0;
+ // Ord is not available in const, so no `.min(N)`
+ let len = if code_units.len() > N {
+ N
+ } else {
+ code_units.len()
+ };
+
+ // Indexing is protected by the len check above
+ #[allow(clippy::indexing_slicing)]
+ while i < len {
+ let b = code_units[i];
+ if b > 0 && b < 0x80 {
+ out[i] = b as u8;
+ } else {
+ out[i] = replacement;
+ }
+ i += 1;
+ }
+
+ Self {
+ // SAFETY: `out` only contains ASCII bytes and has same size as `self.bytes`
+ bytes: unsafe { AsciiByte::to_ascii_byte_array(&out) },
+ }
+ }
+
+ /// Attempts to parse a fixed-length byte array to a `TinyAsciiStr`.
+ ///
+ /// The byte array may contain trailing NUL bytes.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// use tinystr::tinystr;
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// assert_eq!(
+ /// TinyAsciiStr::<3>::try_from_raw(*b"GB\0"),
+ /// Ok(tinystr!(3, "GB"))
+ /// );
+ /// assert_eq!(
+ /// TinyAsciiStr::<3>::try_from_raw(*b"USD"),
+ /// Ok(tinystr!(3, "USD"))
+ /// );
+ /// assert!(matches!(TinyAsciiStr::<3>::try_from_raw(*b"\0A\0"), Err(_)));
+ /// ```
+ pub const fn try_from_raw(raw: [u8; N]) -> Result<Self, ParseError> {
+ Self::try_from_utf8_inner(&raw, true)
+ }
+
+ pub(crate) const fn try_from_utf8_inner(
+ code_units: &[u8],
+ allow_trailing_null: bool,
+ ) -> Result<Self, ParseError> {
+ if code_units.len() > N {
+ return Err(ParseError::TooLong {
+ max: N,
+ len: code_units.len(),
+ });
+ }
+
+ let mut out = [0; N];
+ let mut i = 0;
+ let mut found_null = false;
+ // Indexing is protected by TinyStrError::TooLarge
+ #[allow(clippy::indexing_slicing)]
+ while i < code_units.len() {
+ let b = code_units[i];
+
+ if b == 0 {
+ found_null = true;
+ } else if b >= 0x80 {
+ return Err(ParseError::NonAscii);
+ } else if found_null {
+ // Error if there are contentful bytes after null
+ return Err(ParseError::ContainsNull);
+ }
+ out[i] = b;
+
+ i += 1;
+ }
+
+ if !allow_trailing_null && found_null {
+ // We found some trailing nulls, error
+ return Err(ParseError::ContainsNull);
+ }
+
+ Ok(Self {
+ // SAFETY: `out` only contains ASCII bytes and has same size as `self.bytes`
+ bytes: unsafe { AsciiByte::to_ascii_byte_array(&out) },
+ })
+ }
+
+ pub(crate) const fn try_from_utf16_inner(
+ code_units: &[u16],
+ start: usize,
+ end: usize,
+ allow_trailing_null: bool,
+ ) -> Result<Self, ParseError> {
+ let len = end - start;
+ if len > N {
+ return Err(ParseError::TooLong { max: N, len });
+ }
+
+ let mut out = [0; N];
+ let mut i = 0;
+ let mut found_null = false;
+ // Indexing is protected by TinyStrError::TooLarge
+ #[allow(clippy::indexing_slicing)]
+ while i < len {
+ let b = code_units[start + i];
+
+ if b == 0 {
+ found_null = true;
+ } else if b >= 0x80 {
+ return Err(ParseError::NonAscii);
+ } else if found_null {
+ // Error if there are contentful bytes after null
+ return Err(ParseError::ContainsNull);
+ }
+ out[i] = b as u8;
+
+ i += 1;
+ }
+
+ if !allow_trailing_null && found_null {
+ // We found some trailing nulls, error
+ return Err(ParseError::ContainsNull);
+ }
+
+ Ok(Self {
+ // SAFETY: `out` only contains ASCII bytes and has same size as `self.bytes`
+ bytes: unsafe { AsciiByte::to_ascii_byte_array(&out) },
+ })
+ }
+
+ #[inline]
+ pub const fn as_str(&self) -> &str {
+ // as_utf8 is valid utf8
+ unsafe { str::from_utf8_unchecked(self.as_utf8()) }
+ }
+
+ #[inline]
+ #[must_use]
+ pub const fn len(&self) -> usize {
+ if N <= 4 {
+ Aligned4::from_ascii_bytes(&self.bytes).len()
+ } else if N <= 8 {
+ Aligned8::from_ascii_bytes(&self.bytes).len()
+ } else {
+ let mut i = 0;
+ #[allow(clippy::indexing_slicing)] // < N is safe
+ while i < N && self.bytes[i] as u8 != AsciiByte::B0 as u8 {
+ i += 1
+ }
+ i
+ }
+ }
+
+ #[inline]
+ #[must_use]
+ pub const fn is_empty(&self) -> bool {
+ self.bytes[0] as u8 == AsciiByte::B0 as u8
+ }
+
+ #[inline]
+ #[must_use]
+ pub const fn as_utf8(&self) -> &[u8] {
+ // Safe because `self.bytes.as_slice()` pointer-casts to `&[u8]`,
+ // and changing the length of that slice to self.len() < N is safe.
+ unsafe {
+ core::slice::from_raw_parts(self.bytes.as_slice().as_ptr() as *const u8, self.len())
+ }
+ }
+
+ #[inline]
+ #[must_use]
+ pub const fn all_bytes(&self) -> &[u8; N] {
+ // SAFETY: `self.bytes` has same size as [u8; N]
+ unsafe { &*(self.bytes.as_ptr() as *const [u8; N]) }
+ }
+
+ #[inline]
+ #[must_use]
+ /// Resizes a `TinyAsciiStr<N>` to a `TinyAsciiStr<M>`.
+ ///
+ /// If `M < len()` the string gets truncated, otherwise only the
+ /// memory representation changes.
+ pub const fn resize<const M: usize>(self) -> TinyAsciiStr<M> {
+ let mut bytes = [0; M];
+ let mut i = 0;
+ // Indexing is protected by the loop guard
+ #[allow(clippy::indexing_slicing)]
+ while i < M && i < N {
+ bytes[i] = self.bytes[i] as u8;
+ i += 1;
+ }
+ // `self.bytes` only contains ASCII bytes, with no null bytes between
+ // ASCII characters, so this also holds for `bytes`.
+ unsafe { TinyAsciiStr::from_utf8_unchecked(bytes) }
+ }
+
+ #[inline]
+ #[must_use]
+ /// Returns a `TinyAsciiStr<Q>` with the concatenation of this string,
+ /// `TinyAsciiStr<N>`, and another string, `TinyAsciiStr<M>`.
+ ///
+ /// If `Q < N + M`, the string gets truncated.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::tinystr;
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let abc = tinystr!(6, "abc");
+ /// let defg = tinystr!(6, "defg");
+ ///
+ /// // The concatenation is successful if Q is large enough...
+ /// assert_eq!(abc.concat(defg), tinystr!(16, "abcdefg"));
+ /// assert_eq!(abc.concat(defg), tinystr!(12, "abcdefg"));
+ /// assert_eq!(abc.concat(defg), tinystr!(8, "abcdefg"));
+ /// assert_eq!(abc.concat(defg), tinystr!(7, "abcdefg"));
+ ///
+ /// /// ...but it truncates of Q is too small.
+ /// assert_eq!(abc.concat(defg), tinystr!(6, "abcdef"));
+ /// assert_eq!(abc.concat(defg), tinystr!(2, "ab"));
+ /// ```
+ pub const fn concat<const M: usize, const Q: usize>(
+ self,
+ other: TinyAsciiStr<M>,
+ ) -> TinyAsciiStr<Q> {
+ let mut result = self.resize::<Q>();
+ let mut i = self.len();
+ let mut j = 0;
+ // Indexing is protected by the loop guard
+ #[allow(clippy::indexing_slicing)]
+ while i < Q && j < M {
+ result.bytes[i] = other.bytes[j];
+ i += 1;
+ j += 1;
+ }
+ result
+ }
+
+ /// # Safety
+ /// Must be called with a bytes array made of valid ASCII bytes, with no null bytes
+ /// between ASCII characters
+ #[must_use]
+ pub const unsafe fn from_utf8_unchecked(code_units: [u8; N]) -> Self {
+ Self {
+ bytes: AsciiByte::to_ascii_byte_array(&code_units),
+ }
+ }
+}
+
+macro_rules! check_is {
+ ($self:ident, $check_int:ident, $check_u8:ident) => {
+ if N <= 4 {
+ Aligned4::from_ascii_bytes(&$self.bytes).$check_int()
+ } else if N <= 8 {
+ Aligned8::from_ascii_bytes(&$self.bytes).$check_int()
+ } else {
+ let mut i = 0;
+ // Won't panic because self.bytes has length N
+ #[allow(clippy::indexing_slicing)]
+ while i < N && $self.bytes[i] as u8 != AsciiByte::B0 as u8 {
+ if !($self.bytes[i] as u8).$check_u8() {
+ return false;
+ }
+ i += 1;
+ }
+ true
+ }
+ };
+ ($self:ident, $check_int:ident, !$check_u8_0_inv:ident, !$check_u8_1_inv:ident) => {
+ if N <= 4 {
+ Aligned4::from_ascii_bytes(&$self.bytes).$check_int()
+ } else if N <= 8 {
+ Aligned8::from_ascii_bytes(&$self.bytes).$check_int()
+ } else {
+ // Won't panic because N is > 8
+ if ($self.bytes[0] as u8).$check_u8_0_inv() {
+ return false;
+ }
+ let mut i = 1;
+ // Won't panic because self.bytes has length N
+ #[allow(clippy::indexing_slicing)]
+ while i < N && $self.bytes[i] as u8 != AsciiByte::B0 as u8 {
+ if ($self.bytes[i] as u8).$check_u8_1_inv() {
+ return false;
+ }
+ i += 1;
+ }
+ true
+ }
+ };
+ ($self:ident, $check_int:ident, $check_u8_0_inv:ident, $check_u8_1_inv:ident) => {
+ if N <= 4 {
+ Aligned4::from_ascii_bytes(&$self.bytes).$check_int()
+ } else if N <= 8 {
+ Aligned8::from_ascii_bytes(&$self.bytes).$check_int()
+ } else {
+ // Won't panic because N is > 8
+ if !($self.bytes[0] as u8).$check_u8_0_inv() {
+ return false;
+ }
+ let mut i = 1;
+ // Won't panic because self.bytes has length N
+ #[allow(clippy::indexing_slicing)]
+ while i < N && $self.bytes[i] as u8 != AsciiByte::B0 as u8 {
+ if !($self.bytes[i] as u8).$check_u8_1_inv() {
+ return false;
+ }
+ i += 1;
+ }
+ true
+ }
+ };
+}
+
+impl<const N: usize> TinyAsciiStr<N> {
+ /// Checks if the value is composed of ASCII alphabetic characters:
+ ///
+ /// * U+0041 'A' ..= U+005A 'Z', or
+ /// * U+0061 'a' ..= U+007A 'z'.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "Test".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "Te3t".parse().expect("Failed to parse.");
+ ///
+ /// assert!(s1.is_ascii_alphabetic());
+ /// assert!(!s2.is_ascii_alphabetic());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_alphabetic(&self) -> bool {
+ check_is!(self, is_ascii_alphabetic, is_ascii_alphabetic)
+ }
+
+ /// Checks if the value is composed of ASCII alphanumeric characters:
+ ///
+ /// * U+0041 'A' ..= U+005A 'Z', or
+ /// * U+0061 'a' ..= U+007A 'z', or
+ /// * U+0030 '0' ..= U+0039 '9'.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "A15b".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "[3@w".parse().expect("Failed to parse.");
+ ///
+ /// assert!(s1.is_ascii_alphanumeric());
+ /// assert!(!s2.is_ascii_alphanumeric());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_alphanumeric(&self) -> bool {
+ check_is!(self, is_ascii_alphanumeric, is_ascii_alphanumeric)
+ }
+
+ /// Checks if the value is composed of ASCII decimal digits:
+ ///
+ /// * U+0030 '0' ..= U+0039 '9'.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "312".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "3d".parse().expect("Failed to parse.");
+ ///
+ /// assert!(s1.is_ascii_numeric());
+ /// assert!(!s2.is_ascii_numeric());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_numeric(&self) -> bool {
+ check_is!(self, is_ascii_numeric, is_ascii_digit)
+ }
+
+ /// Checks if the value is in ASCII lower case.
+ ///
+ /// All letter characters are checked for case. Non-letter characters are ignored.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "test".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(!s1.is_ascii_lowercase());
+ /// assert!(s2.is_ascii_lowercase());
+ /// assert!(s3.is_ascii_lowercase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_lowercase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_lowercase,
+ !is_ascii_uppercase,
+ !is_ascii_uppercase
+ )
+ }
+
+ /// Checks if the value is in ASCII title case.
+ ///
+ /// This verifies that the first character is ASCII uppercase and all others ASCII lowercase.
+ /// Non-letter characters are ignored.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "Test".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(!s1.is_ascii_titlecase());
+ /// assert!(s2.is_ascii_titlecase());
+ /// assert!(s3.is_ascii_titlecase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_titlecase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_titlecase,
+ !is_ascii_lowercase,
+ !is_ascii_uppercase
+ )
+ }
+
+ /// Checks if the value is in ASCII upper case.
+ ///
+ /// All letter characters are checked for case. Non-letter characters are ignored.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "TEST".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(!s1.is_ascii_uppercase());
+ /// assert!(s2.is_ascii_uppercase());
+ /// assert!(!s3.is_ascii_uppercase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_uppercase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_uppercase,
+ !is_ascii_lowercase,
+ !is_ascii_lowercase
+ )
+ }
+
+ /// Checks if the value is composed of ASCII alphabetic lower case characters:
+ ///
+ /// * U+0061 'a' ..= U+007A 'z',
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "Test".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "Te3t".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s4: TinyAsciiStr<4> = "test".parse().expect("Failed to parse.");
+ /// let s5: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(!s1.is_ascii_alphabetic_lowercase());
+ /// assert!(!s2.is_ascii_alphabetic_lowercase());
+ /// assert!(!s3.is_ascii_alphabetic_lowercase());
+ /// assert!(s4.is_ascii_alphabetic_lowercase());
+ /// assert!(!s5.is_ascii_alphabetic_lowercase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_alphabetic_lowercase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_alphabetic_lowercase,
+ is_ascii_lowercase,
+ is_ascii_lowercase
+ )
+ }
+
+ /// Checks if the value is composed of ASCII alphabetic, with the first character being ASCII uppercase, and all others ASCII lowercase.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "Test".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "Te3t".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s4: TinyAsciiStr<4> = "test".parse().expect("Failed to parse.");
+ /// let s5: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(s1.is_ascii_alphabetic_titlecase());
+ /// assert!(!s2.is_ascii_alphabetic_titlecase());
+ /// assert!(!s3.is_ascii_alphabetic_titlecase());
+ /// assert!(!s4.is_ascii_alphabetic_titlecase());
+ /// assert!(!s5.is_ascii_alphabetic_titlecase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_alphabetic_titlecase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_alphabetic_titlecase,
+ is_ascii_uppercase,
+ is_ascii_lowercase
+ )
+ }
+
+ /// Checks if the value is composed of ASCII alphabetic upper case characters:
+ ///
+ /// * U+0041 'A' ..= U+005A 'Z',
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "Test".parse().expect("Failed to parse.");
+ /// let s2: TinyAsciiStr<4> = "Te3t".parse().expect("Failed to parse.");
+ /// let s3: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ /// let s4: TinyAsciiStr<4> = "TEST".parse().expect("Failed to parse.");
+ /// let s5: TinyAsciiStr<4> = "001z".parse().expect("Failed to parse.");
+ ///
+ /// assert!(!s1.is_ascii_alphabetic_uppercase());
+ /// assert!(!s2.is_ascii_alphabetic_uppercase());
+ /// assert!(!s3.is_ascii_alphabetic_uppercase());
+ /// assert!(s4.is_ascii_alphabetic_uppercase());
+ /// assert!(!s5.is_ascii_alphabetic_uppercase());
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn is_ascii_alphabetic_uppercase(&self) -> bool {
+ check_is!(
+ self,
+ is_ascii_alphabetic_uppercase,
+ is_ascii_uppercase,
+ is_ascii_uppercase
+ )
+ }
+}
+
+macro_rules! to {
+ ($self:ident, $to:ident, $later_char_to:ident $(,$first_char_to:ident)?) => {{
+ let mut i = 0;
+ if N <= 4 {
+ let aligned = Aligned4::from_ascii_bytes(&$self.bytes).$to().to_ascii_bytes();
+ // Won't panic because self.bytes has length N and aligned has length >= N
+ #[allow(clippy::indexing_slicing)]
+ while i < N {
+ $self.bytes[i] = aligned[i];
+ i += 1;
+ }
+ } else if N <= 8 {
+ let aligned = Aligned8::from_ascii_bytes(&$self.bytes).$to().to_ascii_bytes();
+ // Won't panic because self.bytes has length N and aligned has length >= N
+ #[allow(clippy::indexing_slicing)]
+ while i < N {
+ $self.bytes[i] = aligned[i];
+ i += 1;
+ }
+ } else {
+ // Won't panic because self.bytes has length N
+ #[allow(clippy::indexing_slicing)]
+ while i < N && $self.bytes[i] as u8 != AsciiByte::B0 as u8 {
+ // SAFETY: AsciiByte is repr(u8) and has same size as u8
+ unsafe {
+ $self.bytes[i] = core::mem::transmute::<u8, AsciiByte>(
+ ($self.bytes[i] as u8).$later_char_to()
+ );
+ }
+ i += 1;
+ }
+ // SAFETY: AsciiByte is repr(u8) and has same size as u8
+ $(
+ $self.bytes[0] = unsafe {
+ core::mem::transmute::<u8, AsciiByte>(($self.bytes[0] as u8).$first_char_to())
+ };
+ )?
+ }
+ $self
+ }};
+}
+
+impl<const N: usize> TinyAsciiStr<N> {
+ /// Converts this type to its ASCII lower case equivalent in-place.
+ ///
+ /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z', other characters are unchanged.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "TeS3".parse().expect("Failed to parse.");
+ ///
+ /// assert_eq!(&*s1.to_ascii_lowercase(), "tes3");
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn to_ascii_lowercase(mut self) -> Self {
+ to!(self, to_ascii_lowercase, to_ascii_lowercase)
+ }
+
+ /// Converts this type to its ASCII title case equivalent in-place.
+ ///
+ /// The first character is converted to ASCII uppercase; the remaining characters
+ /// are converted to ASCII lowercase.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "teSt".parse().expect("Failed to parse.");
+ ///
+ /// assert_eq!(&*s1.to_ascii_titlecase(), "Test");
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn to_ascii_titlecase(mut self) -> Self {
+ to!(
+ self,
+ to_ascii_titlecase,
+ to_ascii_lowercase,
+ to_ascii_uppercase
+ )
+ }
+
+ /// Converts this type to its ASCII upper case equivalent in-place.
+ ///
+ /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z', other characters are unchanged.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use tinystr::TinyAsciiStr;
+ ///
+ /// let s1: TinyAsciiStr<4> = "Tes3".parse().expect("Failed to parse.");
+ ///
+ /// assert_eq!(&*s1.to_ascii_uppercase(), "TES3");
+ /// ```
+ #[inline]
+ #[must_use]
+ pub const fn to_ascii_uppercase(mut self) -> Self {
+ to!(self, to_ascii_uppercase, to_ascii_uppercase)
+ }
+}
+
+impl<const N: usize> fmt::Debug for TinyAsciiStr<N> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Debug::fmt(self.as_str(), f)
+ }
+}
+
+impl<const N: usize> fmt::Display for TinyAsciiStr<N> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(self.as_str(), f)
+ }
+}
+
+impl<const N: usize> Deref for TinyAsciiStr<N> {
+ type Target = str;
+ #[inline]
+ fn deref(&self) -> &str {
+ self.as_str()
+ }
+}
+
+impl<const N: usize> Borrow<str> for TinyAsciiStr<N> {
+ #[inline]
+ fn borrow(&self) -> &str {
+ self.as_str()
+ }
+}
+
+impl<const N: usize> FromStr for TinyAsciiStr<N> {
+ type Err = ParseError;
+ #[inline]
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ Self::try_from_str(s)
+ }
+}
+
+impl<const N: usize> PartialEq<str> for TinyAsciiStr<N> {
+ fn eq(&self, other: &str) -> bool {
+ self.deref() == other
+ }
+}
+
+impl<const N: usize> PartialEq<&str> for TinyAsciiStr<N> {
+ fn eq(&self, other: &&str) -> bool {
+ self.deref() == *other
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<const N: usize> PartialEq<alloc::string::String> for TinyAsciiStr<N> {
+ fn eq(&self, other: &alloc::string::String) -> bool {
+ self.deref() == other.deref()
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<const N: usize> PartialEq<TinyAsciiStr<N>> for alloc::string::String {
+ fn eq(&self, other: &TinyAsciiStr<N>) -> bool {
+ self.deref() == other.deref()
+ }
+}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use rand::distributions::Distribution;
+ use rand::distributions::Standard;
+ use rand::rngs::SmallRng;
+ use rand::seq::SliceRandom;
+ use rand::SeedableRng;
+
+ const STRINGS: [&str; 26] = [
+ "Latn",
+ "laTn",
+ "windows",
+ "AR",
+ "Hans",
+ "macos",
+ "AT",
+ "infiniband",
+ "FR",
+ "en",
+ "Cyrl",
+ "FromIntegral",
+ "NO",
+ "419",
+ "MacintoshOSX2019",
+ "a3z",
+ "A3z",
+ "A3Z",
+ "a3Z",
+ "3A",
+ "3Z",
+ "3a",
+ "3z",
+ "@@[`{",
+ "UK",
+ "E12",
+ ];
+
+ fn gen_strings(num_strings: usize, allowed_lengths: &[usize]) -> Vec<String> {
+ let mut rng = SmallRng::seed_from_u64(2022);
+ // Need to do this in 2 steps since the RNG is needed twice
+ let string_lengths = core::iter::repeat_with(|| *allowed_lengths.choose(&mut rng).unwrap())
+ .take(num_strings)
+ .collect::<Vec<usize>>();
+ string_lengths
+ .iter()
+ .map(|len| {
+ Standard
+ .sample_iter(&mut rng)
+ .filter(|b: &u8| *b > 0 && *b < 0x80)
+ .take(*len)
+ .collect::<Vec<u8>>()
+ })
+ .map(|byte_vec| String::from_utf8(byte_vec).expect("All ASCII"))
+ .collect()
+ }
+
+ fn check_operation<T, F1, F2, const N: usize>(reference_f: F1, tinystr_f: F2)
+ where
+ F1: Fn(&str) -> T,
+ F2: Fn(TinyAsciiStr<N>) -> T,
+ T: core::fmt::Debug + core::cmp::PartialEq,
+ {
+ for s in STRINGS
+ .into_iter()
+ .map(str::to_owned)
+ .chain(gen_strings(100, &[3, 4, 5, 8, 12]))
+ {
+ let t = match TinyAsciiStr::<N>::from_str(&s) {
+ Ok(t) => t,
+ Err(ParseError::TooLong { .. }) => continue,
+ Err(e) => panic!("{}", e),
+ };
+ let expected = reference_f(&s);
+ let actual = tinystr_f(t);
+ assert_eq!(expected, actual, "TinyAsciiStr<{N}>: {s:?}");
+
+ let s_utf16: Vec<u16> = s.encode_utf16().collect();
+ let t = match TinyAsciiStr::<N>::try_from_utf16(&s_utf16) {
+ Ok(t) => t,
+ Err(ParseError::TooLong { .. }) => continue,
+ Err(e) => panic!("{}", e),
+ };
+ let expected = reference_f(&s);
+ let actual = tinystr_f(t);
+ assert_eq!(expected, actual, "TinyAsciiStr<{N}>: {s:?}");
+ }
+ }
+
+ #[test]
+ fn test_is_ascii_alphabetic() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| s.chars().all(|c| c.is_ascii_alphabetic()),
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_alphabetic(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_alphanumeric() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| s.chars().all(|c| c.is_ascii_alphanumeric()),
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_alphanumeric(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_numeric() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| s.chars().all(|c| c.is_ascii_digit()),
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_numeric(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_lowercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_lowercase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_lowercase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_titlecase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_titlecase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_titlecase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_uppercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_uppercase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_uppercase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_alphabetic_lowercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ // Check alphabetic
+ s.chars().all(|c| c.is_ascii_alphabetic()) &&
+ // Check lowercase
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_lowercase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_alphabetic_lowercase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_alphabetic_titlecase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ // Check alphabetic
+ s.chars().all(|c| c.is_ascii_alphabetic()) &&
+ // Check titlecase
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_titlecase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_alphabetic_titlecase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_is_ascii_alphabetic_uppercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ // Check alphabetic
+ s.chars().all(|c| c.is_ascii_alphabetic()) &&
+ // Check uppercase
+ s == TinyAsciiStr::<16>::try_from_str(s)
+ .unwrap()
+ .to_ascii_uppercase()
+ .as_str()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::is_ascii_alphabetic_uppercase(&t),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_to_ascii_lowercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ s.chars()
+ .map(|c| c.to_ascii_lowercase())
+ .collect::<String>()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_lowercase(t).as_str().to_owned(),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_to_ascii_titlecase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ let mut r = s
+ .chars()
+ .map(|c| c.to_ascii_lowercase())
+ .collect::<String>();
+ // Safe because the string is nonempty and an ASCII string
+ unsafe { r.as_bytes_mut()[0].make_ascii_uppercase() };
+ r
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_titlecase(t).as_str().to_owned(),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn test_to_ascii_uppercase() {
+ fn check<const N: usize>() {
+ check_operation(
+ |s| {
+ s.chars()
+ .map(|c| c.to_ascii_uppercase())
+ .collect::<String>()
+ },
+ |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_uppercase(t).as_str().to_owned(),
+ )
+ }
+ check::<2>();
+ check::<3>();
+ check::<4>();
+ check::<5>();
+ check::<8>();
+ check::<16>();
+ }
+
+ #[test]
+ fn lossy_constructor() {
+ assert_eq!(TinyAsciiStr::<4>::from_utf8_lossy(b"", b'?').as_str(), "");
+ assert_eq!(
+ TinyAsciiStr::<4>::from_utf8_lossy(b"oh\0o", b'?').as_str(),
+ "oh?o"
+ );
+ assert_eq!(
+ TinyAsciiStr::<4>::from_utf8_lossy(b"\0", b'?').as_str(),
+ "?"
+ );
+ assert_eq!(
+ TinyAsciiStr::<4>::from_utf8_lossy(b"toolong", b'?').as_str(),
+ "tool"
+ );
+ assert_eq!(
+ TinyAsciiStr::<4>::from_utf8_lossy(&[b'a', 0x80, 0xFF, b'1'], b'?').as_str(),
+ "a??1"
+ );
+ }
+}
diff --git a/vendor/tinystr/src/asciibyte.rs b/vendor/tinystr/src/asciibyte.rs
new file mode 100644
index 00000000..f41a0334
--- /dev/null
+++ b/vendor/tinystr/src/asciibyte.rs
@@ -0,0 +1,145 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+#[repr(u8)]
+#[allow(dead_code)]
+#[derive(PartialEq, Eq, Ord, PartialOrd, Copy, Clone, Hash)]
+pub enum AsciiByte {
+ B0 = 0,
+ B1 = 1,
+ B2 = 2,
+ B3 = 3,
+ B4 = 4,
+ B5 = 5,
+ B6 = 6,
+ B7 = 7,
+ B8 = 8,
+ B9 = 9,
+ B10 = 10,
+ B11 = 11,
+ B12 = 12,
+ B13 = 13,
+ B14 = 14,
+ B15 = 15,
+ B16 = 16,
+ B17 = 17,
+ B18 = 18,
+ B19 = 19,
+ B20 = 20,
+ B21 = 21,
+ B22 = 22,
+ B23 = 23,
+ B24 = 24,
+ B25 = 25,
+ B26 = 26,
+ B27 = 27,
+ B28 = 28,
+ B29 = 29,
+ B30 = 30,
+ B31 = 31,
+ B32 = 32,
+ B33 = 33,
+ B34 = 34,
+ B35 = 35,
+ B36 = 36,
+ B37 = 37,
+ B38 = 38,
+ B39 = 39,
+ B40 = 40,
+ B41 = 41,
+ B42 = 42,
+ B43 = 43,
+ B44 = 44,
+ B45 = 45,
+ B46 = 46,
+ B47 = 47,
+ B48 = 48,
+ B49 = 49,
+ B50 = 50,
+ B51 = 51,
+ B52 = 52,
+ B53 = 53,
+ B54 = 54,
+ B55 = 55,
+ B56 = 56,
+ B57 = 57,
+ B58 = 58,
+ B59 = 59,
+ B60 = 60,
+ B61 = 61,
+ B62 = 62,
+ B63 = 63,
+ B64 = 64,
+ B65 = 65,
+ B66 = 66,
+ B67 = 67,
+ B68 = 68,
+ B69 = 69,
+ B70 = 70,
+ B71 = 71,
+ B72 = 72,
+ B73 = 73,
+ B74 = 74,
+ B75 = 75,
+ B76 = 76,
+ B77 = 77,
+ B78 = 78,
+ B79 = 79,
+ B80 = 80,
+ B81 = 81,
+ B82 = 82,
+ B83 = 83,
+ B84 = 84,
+ B85 = 85,
+ B86 = 86,
+ B87 = 87,
+ B88 = 88,
+ B89 = 89,
+ B90 = 90,
+ B91 = 91,
+ B92 = 92,
+ B93 = 93,
+ B94 = 94,
+ B95 = 95,
+ B96 = 96,
+ B97 = 97,
+ B98 = 98,
+ B99 = 99,
+ B100 = 100,
+ B101 = 101,
+ B102 = 102,
+ B103 = 103,
+ B104 = 104,
+ B105 = 105,
+ B106 = 106,
+ B107 = 107,
+ B108 = 108,
+ B109 = 109,
+ B110 = 110,
+ B111 = 111,
+ B112 = 112,
+ B113 = 113,
+ B114 = 114,
+ B115 = 115,
+ B116 = 116,
+ B117 = 117,
+ B118 = 118,
+ B119 = 119,
+ B120 = 120,
+ B121 = 121,
+ B122 = 122,
+ B123 = 123,
+ B124 = 124,
+ B125 = 125,
+ B126 = 126,
+ B127 = 127,
+}
+
+impl AsciiByte {
+ // Convert [u8; N] to [AsciiByte; N]
+ #[inline]
+ pub const unsafe fn to_ascii_byte_array<const N: usize>(bytes: &[u8; N]) -> [AsciiByte; N] {
+ *(bytes as *const [u8; N] as *const [AsciiByte; N])
+ }
+}
diff --git a/vendor/tinystr/src/databake.rs b/vendor/tinystr/src/databake.rs
new file mode 100644
index 00000000..748d23ac
--- /dev/null
+++ b/vendor/tinystr/src/databake.rs
@@ -0,0 +1,75 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::TinyAsciiStr;
+use crate::UnvalidatedTinyAsciiStr;
+use databake::*;
+
+impl<const N: usize> Bake for TinyAsciiStr<N> {
+ fn bake(&self, env: &CrateEnv) -> TokenStream {
+ env.insert("tinystr");
+ let string = self.as_str();
+ quote! {
+ tinystr::tinystr!(#N, #string)
+ }
+ }
+}
+
+impl<const N: usize> BakeSize for TinyAsciiStr<N> {
+ fn borrows_size(&self) -> usize {
+ 0
+ }
+}
+
+impl<const N: usize> databake::Bake for UnvalidatedTinyAsciiStr<N> {
+ fn bake(&self, env: &databake::CrateEnv) -> databake::TokenStream {
+ match self.try_into_tinystr() {
+ Ok(tiny) => {
+ let tiny = tiny.bake(env);
+ databake::quote! {
+ #tiny.to_unvalidated()
+ }
+ }
+ Err(_) => {
+ let bytes = self.0.bake(env);
+ env.insert("tinystr");
+ databake::quote! {
+ tinystr::UnvalidatedTinyAsciiStr::from_utf8_unchecked(#bytes)
+ }
+ }
+ }
+ }
+}
+
+impl<const N: usize> databake::BakeSize for UnvalidatedTinyAsciiStr<N> {
+ fn borrows_size(&self) -> usize {
+ 0
+ }
+}
+
+#[test]
+fn test() {
+ test_bake!(
+ TinyAsciiStr<10>,
+ const,
+ crate::tinystr!(10usize, "foo"),
+ tinystr
+ );
+}
+
+#[test]
+fn test_unvalidated() {
+ test_bake!(
+ UnvalidatedTinyAsciiStr<10>,
+ const,
+ crate::tinystr!(10usize, "foo").to_unvalidated(),
+ tinystr
+ );
+ test_bake!(
+ UnvalidatedTinyAsciiStr<3>,
+ const,
+ crate::UnvalidatedTinyAsciiStr::from_utf8_unchecked(*b"AB\xCD"),
+ tinystr
+ );
+}
diff --git a/vendor/tinystr/src/error.rs b/vendor/tinystr/src/error.rs
new file mode 100644
index 00000000..ea1ab212
--- /dev/null
+++ b/vendor/tinystr/src/error.rs
@@ -0,0 +1,18 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use displaydoc::Display;
+
+impl core::error::Error for ParseError {}
+
+#[derive(Display, Debug, PartialEq, Eq)]
+#[non_exhaustive]
+pub enum ParseError {
+ #[displaydoc("found string of larger length {len} when constructing string of length {max}")]
+ TooLong { max: usize, len: usize },
+ #[displaydoc("tinystr types do not support strings with null bytes")]
+ ContainsNull,
+ #[displaydoc("attempted to construct TinyAsciiStr from a non-ASCII string")]
+ NonAscii,
+}
diff --git a/vendor/tinystr/src/int_ops.rs b/vendor/tinystr/src/int_ops.rs
new file mode 100644
index 00000000..7bdb3633
--- /dev/null
+++ b/vendor/tinystr/src/int_ops.rs
@@ -0,0 +1,315 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::asciibyte::AsciiByte;
+
+/// Internal helper struct that performs operations on aligned integers.
+/// Supports strings up to 4 bytes long.
+#[repr(transparent)]
+pub struct Aligned4(u32);
+
+impl Aligned4 {
+ /// # Panics
+ /// Panics if N is greater than 4
+ #[inline]
+ pub const fn from_utf8<const N: usize>(src: &[u8; N]) -> Self {
+ let mut bytes = [0; 4];
+ let mut i = 0;
+ // The function documentation defines when panics may occur
+ #[allow(clippy::indexing_slicing)]
+ while i < N {
+ bytes[i] = src[i];
+ i += 1;
+ }
+ Self(u32::from_ne_bytes(bytes))
+ }
+
+ #[inline]
+ pub const fn from_ascii_bytes<const N: usize>(src: &[AsciiByte; N]) -> Self {
+ Self::from_utf8::<N>(unsafe { core::mem::transmute::<&[AsciiByte; N], &[u8; N]>(src) })
+ }
+
+ #[inline]
+ pub const fn to_bytes(&self) -> [u8; 4] {
+ self.0.to_ne_bytes()
+ }
+
+ #[inline]
+ pub const fn to_ascii_bytes(&self) -> [AsciiByte; 4] {
+ unsafe { core::mem::transmute(self.to_bytes()) }
+ }
+
+ pub const fn len(&self) -> usize {
+ let word = self.0;
+ #[cfg(target_endian = "little")]
+ let len = (4 - word.leading_zeros() / 8) as usize;
+ #[cfg(target_endian = "big")]
+ let len = (4 - word.trailing_zeros() / 8) as usize;
+ len
+ }
+
+ pub const fn is_ascii_alphabetic(&self) -> bool {
+ let word = self.0;
+ // Each of the following bitmasks set *the high bit* (0x8) to 0 for valid and 1 for invalid.
+ // `mask` sets all NUL bytes to 0.
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ // `lower` converts the string to lowercase. It may also change the value of non-alpha
+ // characters, but this does not matter for the alphabetic test that follows.
+ let lower = word | 0x2020_2020;
+ // `alpha` sets all alphabetic bytes to 0. We only need check for lowercase characters.
+ let alpha = !(lower + 0x1f1f_1f1f) | (lower + 0x0505_0505);
+ // The overall string is valid if every character passes at least one test.
+ // We performed two tests here: non-NUL (`mask`) and alphabetic (`alpha`).
+ (alpha & mask) == 0
+ }
+
+ pub const fn is_ascii_alphanumeric(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ let numeric = !(word + 0x5050_5050) | (word + 0x4646_4646);
+ let lower = word | 0x2020_2020;
+ let alpha = !(lower + 0x1f1f_1f1f) | (lower + 0x0505_0505);
+ (alpha & numeric & mask) == 0
+ }
+
+ pub const fn is_ascii_numeric(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ let numeric = !(word + 0x5050_5050) | (word + 0x4646_4646);
+ (numeric & mask) == 0
+ }
+
+ pub const fn is_ascii_lowercase(&self) -> bool {
+ let word = self.0;
+ // For efficiency, this function tests for an invalid string rather than a valid string.
+ // A string is ASCII lowercase iff it contains no uppercase ASCII characters.
+ // `invalid_case` sets all uppercase ASCII characters to 0 and all others to 1.
+ let invalid_case = !(word + 0x3f3f_3f3f) | (word + 0x2525_2525);
+ // The string is valid if it contains no invalid characters (if all high bits are 1).
+ (invalid_case & 0x8080_8080) == 0x8080_8080
+ }
+
+ pub const fn is_ascii_titlecase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_lowercase
+ let invalid_case = if cfg!(target_endian = "little") {
+ !(word + 0x3f3f_3f1f) | (word + 0x2525_2505)
+ } else {
+ !(word + 0x1f3f_3f3f) | (word + 0x0525_2525)
+ };
+ (invalid_case & 0x8080_8080) == 0x8080_8080
+ }
+
+ pub const fn is_ascii_uppercase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_lowercase
+ let invalid_case = !(word + 0x1f1f_1f1f) | (word + 0x0505_0505);
+ (invalid_case & 0x8080_8080) == 0x8080_8080
+ }
+
+ pub const fn is_ascii_alphabetic_lowercase(&self) -> bool {
+ let word = self.0;
+ // `mask` sets all NUL bytes to 0.
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ // `lower_alpha` sets all lowercase ASCII characters to 0 and all others to 1.
+ let lower_alpha = !(word + 0x1f1f_1f1f) | (word + 0x0505_0505);
+ // The overall string is valid if every character passes at least one test.
+ // We performed two tests here: non-NUL (`mask`) and lowercase ASCII character (`alpha`).
+ (lower_alpha & mask) == 0
+ }
+
+ pub const fn is_ascii_alphabetic_titlecase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic_lowercase
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ let title_case = if cfg!(target_endian = "little") {
+ !(word + 0x1f1f_1f3f) | (word + 0x0505_0525)
+ } else {
+ !(word + 0x3f1f_1f1f) | (word + 0x2505_0505)
+ };
+ (title_case & mask) == 0
+ }
+
+ pub const fn is_ascii_alphabetic_uppercase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic_lowercase
+ let mask = (word + 0x7f7f_7f7f) & 0x8080_8080;
+ let upper_alpha = !(word + 0x3f3f_3f3f) | (word + 0x2525_2525);
+ (upper_alpha & mask) == 0
+ }
+
+ pub const fn to_ascii_lowercase(&self) -> Self {
+ let word = self.0;
+ let result = word | (((word + 0x3f3f_3f3f) & !(word + 0x2525_2525) & 0x8080_8080) >> 2);
+ Self(result)
+ }
+
+ pub const fn to_ascii_titlecase(&self) -> Self {
+ let word = self.0.to_le();
+ let mask = ((word + 0x3f3f_3f1f) & !(word + 0x2525_2505) & 0x8080_8080) >> 2;
+ let result = (word | mask) & !(0x20 & mask);
+ Self(u32::from_le(result))
+ }
+
+ pub const fn to_ascii_uppercase(&self) -> Self {
+ let word = self.0;
+ let result = word & !(((word + 0x1f1f_1f1f) & !(word + 0x0505_0505) & 0x8080_8080) >> 2);
+ Self(result)
+ }
+}
+
+/// Internal helper struct that performs operations on aligned integers.
+/// Supports strings up to 8 bytes long.
+#[repr(transparent)]
+pub struct Aligned8(u64);
+
+impl Aligned8 {
+ /// # Panics
+ /// Panics if N is greater than 8
+ #[inline]
+ pub const fn from_utf8<const N: usize>(src: &[u8; N]) -> Self {
+ let mut bytes = [0; 8];
+ let mut i = 0;
+ // The function documentation defines when panics may occur
+ #[allow(clippy::indexing_slicing)]
+ while i < N {
+ bytes[i] = src[i];
+ i += 1;
+ }
+ Self(u64::from_ne_bytes(bytes))
+ }
+
+ #[inline]
+ pub const fn from_ascii_bytes<const N: usize>(src: &[AsciiByte; N]) -> Self {
+ Self::from_utf8::<N>(unsafe { core::mem::transmute::<&[AsciiByte; N], &[u8; N]>(src) })
+ }
+
+ #[inline]
+ pub const fn to_bytes(&self) -> [u8; 8] {
+ self.0.to_ne_bytes()
+ }
+
+ #[inline]
+ pub const fn to_ascii_bytes(&self) -> [AsciiByte; 8] {
+ unsafe { core::mem::transmute(self.to_bytes()) }
+ }
+
+ pub const fn len(&self) -> usize {
+ let word = self.0;
+ #[cfg(target_endian = "little")]
+ let len = (8 - word.leading_zeros() / 8) as usize;
+ #[cfg(target_endian = "big")]
+ let len = (8 - word.trailing_zeros() / 8) as usize;
+ len
+ }
+
+ pub const fn is_ascii_alphabetic(&self) -> bool {
+ let word = self.0;
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ let lower = word | 0x2020_2020_2020_2020;
+ let alpha = !(lower + 0x1f1f_1f1f_1f1f_1f1f) | (lower + 0x0505_0505_0505_0505);
+ (alpha & mask) == 0
+ }
+
+ pub const fn is_ascii_alphanumeric(&self) -> bool {
+ let word = self.0;
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ let numeric = !(word + 0x5050_5050_5050_5050) | (word + 0x4646_4646_4646_4646);
+ let lower = word | 0x2020_2020_2020_2020;
+ let alpha = !(lower + 0x1f1f_1f1f_1f1f_1f1f) | (lower + 0x0505_0505_0505_0505);
+ (alpha & numeric & mask) == 0
+ }
+
+ pub const fn is_ascii_numeric(&self) -> bool {
+ let word = self.0;
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ let numeric = !(word + 0x5050_5050_5050_5050) | (word + 0x4646_4646_4646_4646);
+ (numeric & mask) == 0
+ }
+
+ pub const fn is_ascii_lowercase(&self) -> bool {
+ let word = self.0;
+ let invalid_case = !(word + 0x3f3f_3f3f_3f3f_3f3f) | (word + 0x2525_2525_2525_2525);
+ (invalid_case & 0x8080_8080_8080_8080) == 0x8080_8080_8080_8080
+ }
+
+ pub const fn is_ascii_titlecase(&self) -> bool {
+ let word = self.0;
+ let invalid_case = if cfg!(target_endian = "little") {
+ !(word + 0x3f3f_3f3f_3f3f_3f1f) | (word + 0x2525_2525_2525_2505)
+ } else {
+ !(word + 0x1f3f_3f3f_3f3f_3f3f) | (word + 0x0525_2525_2525_2525)
+ };
+ (invalid_case & 0x8080_8080_8080_8080) == 0x8080_8080_8080_8080
+ }
+
+ pub const fn is_ascii_uppercase(&self) -> bool {
+ let word = self.0;
+ let invalid_case = !(word + 0x1f1f_1f1f_1f1f_1f1f) | (word + 0x0505_0505_0505_0505);
+ (invalid_case & 0x8080_8080_8080_8080) == 0x8080_8080_8080_8080
+ }
+
+ pub const fn is_ascii_alphabetic_lowercase(&self) -> bool {
+ let word = self.0;
+ // `mask` sets all NUL bytes to 0.
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ // `lower_alpha` sets all lowercase ASCII characters to 0 and all others to 1.
+ let lower_alpha = !(word + 0x1f1f_1f1f_1f1f_1f1f) | (word + 0x0505_0505_0505_0505);
+ // The overall string is valid if every character passes at least one test.
+ // We performed two tests here: non-NUL (`mask`) and lowercase ASCII character (`alpha`).
+ (lower_alpha & mask) == 0
+ }
+
+ pub const fn is_ascii_alphabetic_titlecase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic_lowercase
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ let title_case = if cfg!(target_endian = "little") {
+ !(word + 0x1f1f_1f1f_1f1f_1f3f) | (word + 0x0505_0505_0505_0525)
+ } else {
+ !(word + 0x3f1f_1f1f_1f1f_1f1f) | (word + 0x2505_0505_0505_0505)
+ };
+ (title_case & mask) == 0
+ }
+
+ pub const fn is_ascii_alphabetic_uppercase(&self) -> bool {
+ let word = self.0;
+ // See explanatory comments in is_ascii_alphabetic_lowercase
+ let mask = (word + 0x7f7f_7f7f_7f7f_7f7f) & 0x8080_8080_8080_8080;
+ let upper_alpha = !(word + 0x3f3f_3f3f_3f3f_3f3f) | (word + 0x2525_2525_2525_2525);
+ (upper_alpha & mask) == 0
+ }
+
+ pub const fn to_ascii_lowercase(&self) -> Self {
+ let word = self.0;
+ let result = word
+ | (((word + 0x3f3f_3f3f_3f3f_3f3f)
+ & !(word + 0x2525_2525_2525_2525)
+ & 0x8080_8080_8080_8080)
+ >> 2);
+ Self(result)
+ }
+
+ pub const fn to_ascii_titlecase(&self) -> Self {
+ let word = self.0.to_le();
+ let mask = ((word + 0x3f3f_3f3f_3f3f_3f1f)
+ & !(word + 0x2525_2525_2525_2505)
+ & 0x8080_8080_8080_8080)
+ >> 2;
+ let result = (word | mask) & !(0x20 & mask);
+ Self(u64::from_le(result))
+ }
+
+ pub const fn to_ascii_uppercase(&self) -> Self {
+ let word = self.0;
+ let result = word
+ & !(((word + 0x1f1f_1f1f_1f1f_1f1f)
+ & !(word + 0x0505_0505_0505_0505)
+ & 0x8080_8080_8080_8080)
+ >> 2);
+ Self(result)
+ }
+}
diff --git a/vendor/tinystr/src/lib.rs b/vendor/tinystr/src/lib.rs
new file mode 100644
index 00000000..19440720
--- /dev/null
+++ b/vendor/tinystr/src/lib.rs
@@ -0,0 +1,114 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! `tinystr` is a utility crate of the [`ICU4X`] project.
+//!
+//! It includes [`TinyAsciiStr`], a core API for representing small ASCII-only bounded length strings.
+//!
+//! It is optimized for operations on strings of size 8 or smaller. When use cases involve comparison
+//! and conversion of strings for lowercase/uppercase/titlecase, or checking
+//! numeric/alphabetic/alphanumeric, `TinyAsciiStr` is the edge performance library.
+//!
+//! # Examples
+//!
+//! ```rust
+//! use tinystr::TinyAsciiStr;
+//!
+//! let s1: TinyAsciiStr<4> = "tEsT".parse().expect("Failed to parse.");
+//!
+//! assert_eq!(s1, "tEsT");
+//! assert_eq!(s1.to_ascii_uppercase(), "TEST");
+//! assert_eq!(s1.to_ascii_lowercase(), "test");
+//! assert_eq!(s1.to_ascii_titlecase(), "Test");
+//! assert!(s1.is_ascii_alphanumeric());
+//! assert!(!s1.is_ascii_numeric());
+//!
+//! let s2 = TinyAsciiStr::<8>::try_from_raw(*b"New York")
+//! .expect("Failed to parse.");
+//!
+//! assert_eq!(s2, "New York");
+//! assert_eq!(s2.to_ascii_uppercase(), "NEW YORK");
+//! assert_eq!(s2.to_ascii_lowercase(), "new york");
+//! assert_eq!(s2.to_ascii_titlecase(), "New york");
+//! assert!(!s2.is_ascii_alphanumeric());
+//! ```
+//!
+//! # Details
+//!
+//! When strings are of size 8 or smaller, the struct transforms the strings as `u32`/`u64` and uses
+//! bitmasking to provide basic string manipulation operations:
+//! * `is_ascii_numeric`
+//! * `is_ascii_alphabetic`
+//! * `is_ascii_alphanumeric`
+//! * `to_ascii_lowercase`
+//! * `to_ascii_uppercase`
+//! * `to_ascii_titlecase`
+//! * `PartialEq`
+//!
+//! `TinyAsciiStr` will fall back to `u8` character manipulation for strings of length greater than 8.
+
+//!
+//! [`ICU4X`]: ../icu/index.html
+
+// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
+#![cfg_attr(not(any(test, doc)), no_std)]
+#![cfg_attr(
+ not(test),
+ deny(
+ clippy::indexing_slicing,
+ clippy::unwrap_used,
+ clippy::expect_used,
+ clippy::panic,
+ clippy::exhaustive_structs,
+ clippy::exhaustive_enums,
+ clippy::trivially_copy_pass_by_ref,
+ missing_debug_implementations,
+ )
+)]
+
+mod macros;
+
+mod ascii;
+mod asciibyte;
+mod error;
+mod int_ops;
+mod unvalidated;
+
+#[cfg(feature = "serde")]
+mod serde;
+
+#[cfg(feature = "databake")]
+mod databake;
+
+#[cfg(feature = "zerovec")]
+mod ule;
+
+#[cfg(any(feature = "serde", feature = "alloc"))]
+extern crate alloc;
+
+pub use ascii::TinyAsciiStr;
+pub use error::ParseError;
+pub use unvalidated::UnvalidatedTinyAsciiStr;
+
+/// These are temporary compatability reexports that will be removed
+/// in a future version.
+pub type TinyStr4 = TinyAsciiStr<4>;
+/// These are temporary compatability reexports that will be removed
+/// in a future version.
+pub type TinyStr8 = TinyAsciiStr<8>;
+/// These are temporary compatability reexports that will be removed
+/// in a future version.
+pub type TinyStr16 = TinyAsciiStr<16>;
+
+#[test]
+fn test_size() {
+ assert_eq!(
+ core::mem::size_of::<TinyStr4>(),
+ core::mem::size_of::<Option<TinyStr4>>()
+ );
+ assert_eq!(
+ core::mem::size_of::<TinyStr8>(),
+ core::mem::size_of::<Option<TinyStr8>>()
+ );
+}
diff --git a/vendor/tinystr/src/macros.rs b/vendor/tinystr/src/macros.rs
new file mode 100644
index 00000000..30dc445e
--- /dev/null
+++ b/vendor/tinystr/src/macros.rs
@@ -0,0 +1,32 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+#[macro_export]
+macro_rules! tinystr {
+ ($n:literal, $s:literal) => {{
+ // Force it into a const context; otherwise it may get evaluated at runtime instead.
+ const TINYSTR_MACRO_CONST: $crate::TinyAsciiStr<$n> = {
+ match $crate::TinyAsciiStr::try_from_utf8($s.as_bytes()) {
+ Ok(s) => s,
+ // We are okay with panicking here because this is in a const context
+ #[allow(clippy::panic)]
+ // Cannot format the error since formatting isn't const yet
+ Err(_) => panic!(concat!("Failed to construct tinystr from ", $s)),
+ }
+ };
+ TINYSTR_MACRO_CONST
+ }};
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn test_macro_construction() {
+ let s1 = tinystr!(8, "foobar");
+ assert_eq!(&*s1, "foobar");
+
+ let s1 = tinystr!(12, "foobarbaz");
+ assert_eq!(&*s1, "foobarbaz");
+ }
+}
diff --git a/vendor/tinystr/src/serde.rs b/vendor/tinystr/src/serde.rs
new file mode 100644
index 00000000..529902b5
--- /dev/null
+++ b/vendor/tinystr/src/serde.rs
@@ -0,0 +1,91 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::TinyAsciiStr;
+use alloc::borrow::Cow;
+use alloc::string::ToString;
+use core::fmt;
+use core::marker::PhantomData;
+use core::ops::Deref;
+use serde::de::{Error, SeqAccess, Visitor};
+use serde::ser::SerializeTuple;
+use serde::{Deserialize, Deserializer, Serialize, Serializer};
+
+impl<const N: usize> Serialize for TinyAsciiStr<N> {
+ #[inline]
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ if serializer.is_human_readable() {
+ self.deref().serialize(serializer)
+ } else {
+ let mut seq = serializer.serialize_tuple(N)?;
+ for byte in self.all_bytes() {
+ seq.serialize_element(byte)?;
+ }
+ seq.end()
+ }
+ }
+}
+
+struct TinyAsciiStrVisitor<const N: usize> {
+ marker: PhantomData<TinyAsciiStr<N>>,
+}
+
+impl<const N: usize> TinyAsciiStrVisitor<N> {
+ fn new() -> Self {
+ TinyAsciiStrVisitor {
+ marker: PhantomData,
+ }
+ }
+}
+
+impl<'de, const N: usize> Visitor<'de> for TinyAsciiStrVisitor<N> {
+ type Value = TinyAsciiStr<N>;
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ write!(formatter, "a TinyAsciiStr<{N}>")
+ }
+
+ #[inline]
+ fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
+ where
+ A: SeqAccess<'de>,
+ {
+ let mut bytes = [0u8; N];
+ let mut zeroes = false;
+ for out in &mut bytes.iter_mut().take(N) {
+ let byte = seq
+ .next_element()?
+ .ok_or_else(|| Error::invalid_length(N, &self))?;
+ if byte == 0 {
+ zeroes = true;
+ } else if zeroes {
+ return Err(Error::custom("TinyAsciiStr cannot contain null bytes"));
+ }
+
+ if byte >= 0x80 {
+ return Err(Error::custom("TinyAsciiStr cannot contain non-ascii bytes"));
+ }
+ *out = byte;
+ }
+
+ Ok(unsafe { TinyAsciiStr::from_utf8_unchecked(bytes) })
+ }
+}
+
+impl<'de, const N: usize> Deserialize<'de> for TinyAsciiStr<N> {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ if deserializer.is_human_readable() {
+ let x: Cow<'de, str> = Deserialize::deserialize(deserializer)?;
+ TinyAsciiStr::try_from_str(&x).map_err(|e| Error::custom(e.to_string()))
+ } else {
+ deserializer.deserialize_tuple(N, TinyAsciiStrVisitor::<N>::new())
+ }
+ }
+}
diff --git a/vendor/tinystr/src/ule.rs b/vendor/tinystr/src/ule.rs
new file mode 100644
index 00000000..0dd10ff7
--- /dev/null
+++ b/vendor/tinystr/src/ule.rs
@@ -0,0 +1,125 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::{TinyAsciiStr, UnvalidatedTinyAsciiStr};
+#[cfg(feature = "alloc")]
+use zerovec::maps::ZeroMapKV;
+use zerovec::ule::*;
+#[cfg(feature = "alloc")]
+use zerovec::{ZeroSlice, ZeroVec};
+
+// Safety (based on the safety checklist on the ULE trait):
+// 1. TinyAsciiStr does not include any uninitialized or padding bytes.
+// (achieved by `#[repr(transparent)]` on a type that satisfies this invariant)
+// 2. TinyAsciiStr is aligned to 1 byte.
+// (achieved by `#[repr(transparent)]` on a type that satisfies this invariant)
+// 3. The impl of validate_bytes() returns an error if any byte is not valid.
+// 4. The impl of validate_bytes() returns an error if there are extra bytes.
+// 5. The other ULE methods use the default impl.
+// 6. TinyAsciiStr byte equality is semantic equality
+unsafe impl<const N: usize> ULE for TinyAsciiStr<N> {
+ #[inline]
+ fn validate_bytes(bytes: &[u8]) -> Result<(), UleError> {
+ if bytes.len() % N != 0 {
+ return Err(UleError::length::<Self>(bytes.len()));
+ }
+ // Validate the bytes
+ for chunk in bytes.chunks_exact(N) {
+ let _ = TinyAsciiStr::<N>::try_from_utf8_inner(chunk, true)
+ .map_err(|_| UleError::parse::<Self>())?;
+ }
+ Ok(())
+ }
+}
+
+impl<const N: usize> NicheBytes<N> for TinyAsciiStr<N> {
+ // AsciiByte is 0..128
+ const NICHE_BIT_PATTERN: [u8; N] = [255; N];
+}
+
+impl<const N: usize> AsULE for TinyAsciiStr<N> {
+ type ULE = Self;
+
+ #[inline]
+ fn to_unaligned(self) -> Self::ULE {
+ self
+ }
+
+ #[inline]
+ fn from_unaligned(unaligned: Self::ULE) -> Self {
+ unaligned
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<'a, const N: usize> ZeroMapKV<'a> for TinyAsciiStr<N> {
+ type Container = ZeroVec<'a, TinyAsciiStr<N>>;
+ type Slice = ZeroSlice<TinyAsciiStr<N>>;
+ type GetType = TinyAsciiStr<N>;
+ type OwnedType = TinyAsciiStr<N>;
+}
+
+// Safety (based on the safety checklist on the ULE trait):
+// 1. UnvalidatedTinyAsciiStr does not include any uninitialized or padding bytes.
+// (achieved by `#[repr(transparent)]` on a type that satisfies this invariant)
+// 2. UnvalidatedTinyAsciiStr is aligned to 1 byte.
+// (achieved by `#[repr(transparent)]` on a type that satisfies this invariant)
+// 3. The impl of validate_bytes() returns an error if any byte is not valid.
+// 4. The impl of validate_bytes() returns an error if there are extra bytes.
+// 5. The other ULE methods use the default impl.
+// 6. UnvalidatedTinyAsciiStr byte equality is semantic equality
+unsafe impl<const N: usize> ULE for UnvalidatedTinyAsciiStr<N> {
+ #[inline]
+ fn validate_bytes(bytes: &[u8]) -> Result<(), UleError> {
+ if bytes.len() % N != 0 {
+ return Err(UleError::length::<Self>(bytes.len()));
+ }
+ Ok(())
+ }
+}
+
+impl<const N: usize> AsULE for UnvalidatedTinyAsciiStr<N> {
+ type ULE = Self;
+
+ #[inline]
+ fn to_unaligned(self) -> Self::ULE {
+ self
+ }
+
+ #[inline]
+ fn from_unaligned(unaligned: Self::ULE) -> Self {
+ unaligned
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<'a, const N: usize> ZeroMapKV<'a> for UnvalidatedTinyAsciiStr<N> {
+ type Container = ZeroVec<'a, UnvalidatedTinyAsciiStr<N>>;
+ type Slice = ZeroSlice<UnvalidatedTinyAsciiStr<N>>;
+ type GetType = UnvalidatedTinyAsciiStr<N>;
+ type OwnedType = UnvalidatedTinyAsciiStr<N>;
+}
+
+#[cfg(test)]
+mod test {
+ use crate::*;
+ use zerovec::*;
+
+ #[test]
+ fn test_zerovec() {
+ let mut vec = ZeroVec::<TinyAsciiStr<7>>::new();
+
+ vec.with_mut(|v| v.push("foobar".parse().unwrap()));
+ vec.with_mut(|v| v.push("baz".parse().unwrap()));
+ vec.with_mut(|v| v.push("quux".parse().unwrap()));
+
+ let bytes = vec.as_bytes();
+
+ let vec: ZeroVec<TinyAsciiStr<7>> = ZeroVec::parse_bytes(bytes).unwrap();
+
+ assert_eq!(&*vec.get(0).unwrap(), "foobar");
+ assert_eq!(&*vec.get(1).unwrap(), "baz");
+ assert_eq!(&*vec.get(2).unwrap(), "quux");
+ }
+}
diff --git a/vendor/tinystr/src/unvalidated.rs b/vendor/tinystr/src/unvalidated.rs
new file mode 100644
index 00000000..3758b64f
--- /dev/null
+++ b/vendor/tinystr/src/unvalidated.rs
@@ -0,0 +1,122 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::ParseError;
+use crate::TinyAsciiStr;
+use core::fmt;
+
+/// A fixed-length bytes array that is expected to be an ASCII string but does not enforce that invariant.
+///
+/// Use this type instead of `TinyAsciiStr` if you don't need to enforce ASCII during deserialization. For
+/// example, strings that are keys of a map don't need to ever be reified as `TinyAsciiStr`s.
+///
+/// The main advantage of this type over `[u8; N]` is that it serializes as a string in
+/// human-readable formats like JSON.
+#[derive(PartialEq, PartialOrd, Eq, Ord, Clone, Copy)]
+pub struct UnvalidatedTinyAsciiStr<const N: usize>(pub(crate) [u8; N]);
+
+impl<const N: usize> fmt::Debug for UnvalidatedTinyAsciiStr<N> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ // Debug as a string if possible
+ match self.try_into_tinystr() {
+ Ok(s) => fmt::Debug::fmt(&s, f),
+ Err(_) => fmt::Debug::fmt(&self.0, f),
+ }
+ }
+}
+
+impl<const N: usize> UnvalidatedTinyAsciiStr<N> {
+ #[inline]
+ /// Converts into a [`TinyAsciiStr`]. Fails if the bytes are not valid ASCII.
+ pub fn try_into_tinystr(self) -> Result<TinyAsciiStr<N>, ParseError> {
+ TinyAsciiStr::try_from_raw(self.0)
+ }
+
+ #[inline]
+ /// Unsafely converts into a [`TinyAsciiStr`].
+ pub const fn from_utf8_unchecked(bytes: [u8; N]) -> Self {
+ Self(bytes)
+ }
+}
+
+impl<const N: usize> TinyAsciiStr<N> {
+ #[inline]
+ // Converts into a [`UnvalidatedTinyAsciiStr`]
+ pub const fn to_unvalidated(self) -> UnvalidatedTinyAsciiStr<N> {
+ UnvalidatedTinyAsciiStr(*self.all_bytes())
+ }
+}
+
+impl<const N: usize> From<TinyAsciiStr<N>> for UnvalidatedTinyAsciiStr<N> {
+ fn from(other: TinyAsciiStr<N>) -> Self {
+ other.to_unvalidated()
+ }
+}
+
+#[cfg(feature = "serde")]
+impl<const N: usize> serde::Serialize for UnvalidatedTinyAsciiStr<N> {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: serde::Serializer,
+ {
+ use serde::ser::Error;
+ self.try_into_tinystr()
+ .map_err(|_| S::Error::custom("invalid ascii in UnvalidatedTinyAsciiStr"))?
+ .serialize(serializer)
+ }
+}
+
+macro_rules! deserialize {
+ ($size:literal) => {
+ #[cfg(feature = "serde")]
+ impl<'de, 'a> serde::Deserialize<'de> for UnvalidatedTinyAsciiStr<$size>
+ where
+ 'de: 'a,
+ {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: serde::Deserializer<'de>,
+ {
+ if deserializer.is_human_readable() {
+ Ok(TinyAsciiStr::deserialize(deserializer)?.to_unvalidated())
+ } else {
+ Ok(Self(<[u8; $size]>::deserialize(deserializer)?))
+ }
+ }
+ }
+ };
+}
+
+deserialize!(1);
+deserialize!(2);
+deserialize!(3);
+deserialize!(4);
+deserialize!(5);
+deserialize!(6);
+deserialize!(7);
+deserialize!(8);
+deserialize!(9);
+deserialize!(10);
+deserialize!(11);
+deserialize!(12);
+deserialize!(13);
+deserialize!(14);
+deserialize!(15);
+deserialize!(16);
+deserialize!(17);
+deserialize!(18);
+deserialize!(19);
+deserialize!(20);
+deserialize!(21);
+deserialize!(22);
+deserialize!(23);
+deserialize!(24);
+deserialize!(25);
+deserialize!(26);
+deserialize!(27);
+deserialize!(28);
+deserialize!(29);
+deserialize!(30);
+deserialize!(31);
+deserialize!(32);
diff --git a/vendor/tinystr/tests/serde.rs b/vendor/tinystr/tests/serde.rs
new file mode 100644
index 00000000..282914e6
--- /dev/null
+++ b/vendor/tinystr/tests/serde.rs
@@ -0,0 +1,39 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use tinystr::*;
+
+// Tests largely adapted from `tinystr` crate
+// https://github.com/zbraniecki/tinystr/blob/4e4eab55dd6bded7f29a18b41452c506c461716c/tests/serde.rs
+
+macro_rules! test_roundtrip {
+ ($f:ident, $n:literal, $val:expr) => {
+ #[test]
+ fn $f() {
+ let tiny: TinyAsciiStr<$n> = $val.parse().unwrap();
+ let json_string = serde_json::to_string(&tiny).unwrap();
+ let expected_json = concat!("\"", $val, "\"");
+ assert_eq!(json_string, expected_json);
+ let recover: TinyAsciiStr<$n> = serde_json::from_str(&json_string).unwrap();
+ assert_eq!(&*tiny, &*recover);
+
+ let bin = bincode::serialize(&tiny).unwrap();
+ assert_eq!(bin, &tiny.all_bytes()[..]);
+ let debin: TinyAsciiStr<$n> = bincode::deserialize(&bin).unwrap();
+ assert_eq!(&*tiny, &*debin);
+
+ let post = postcard::to_stdvec(&tiny).unwrap();
+ assert_eq!(post, &tiny.all_bytes()[..]);
+ let unpost: TinyAsciiStr<$n> = postcard::from_bytes(&post).unwrap();
+ assert_eq!(&*tiny, &*unpost);
+ }
+ };
+}
+
+test_roundtrip!(test_roundtrip4_1, 4, "en");
+test_roundtrip!(test_roundtrip4_2, 4, "Latn");
+test_roundtrip!(test_roundtrip8, 8, "calendar");
+test_roundtrip!(test_roundtrip16, 16, "verylongstring");
+test_roundtrip!(test_roundtrip10, 11, "shortstring");
+test_roundtrip!(test_roundtrip30, 24, "veryveryverylongstring");