chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

1
vendor/deranged/.cargo-checksum.json vendored Normal file
View File

@@ -0,0 +1 @@
{"files":{".cargo_vcs_info.json":"1ff84e3dd07cfa9cf852b305d813c9faf37630b47b1da1da2b52387cff9200f9","Cargo.lock":"34be0e41ca1808f3e2d06ea2e219f0c7623a67eeef15f9779835bba6de8619df","Cargo.toml":"11c43ed884a6ab8426824a5387a4f06cb4489894b6baf02c0de3410ed5f62646","Cargo.toml.orig":"60931aefce3df7be0efb6c5d619e3913417fb6381cd8d5eacb0b69fabd7459af","LICENSE-Apache":"edd65bdd88957a205c47d53fa499eed8865a70320f0f03f6391668cb304ea376","LICENSE-MIT":"231c837c45eb53f108fb48929e488965bc4fcc14e9ea21d35f50e6b99d98685b","README.md":"fc4c9482d9e5225630da44e5371d6fa3f37220e2f4da2dac076cf4cd4f9592e7","src/lib.rs":"e3b3073e6e4b7a0c1fcb08e4b0872cf39d3951b89d29e283237f3a765da7edbe","src/tests.rs":"875c96ef671c2ed549d1e52f7a077bc8b0659eb7a2e539e58bb64ae6f7135196","src/unsafe_wrapper.rs":"76e67ff03b31f0b97849f0e6c3131f1cb213fc25a11ed259664f48a6901c623e"},"package":"7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"}

6
vendor/deranged/.cargo_vcs_info.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "7d0c671e8c806b96d582af197df3c620e09cb33b"
},
"path_in_vcs": "deranged"
}

645
vendor/deranged/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,645 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anyhow"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chacha20"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
dependencies = [
"cfg-if",
"cpufeatures",
"rand_core 0.10.0",
]
[[package]]
name = "cpufeatures"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
dependencies = [
"libc",
]
[[package]]
name = "deranged"
version = "0.5.8"
dependencies = [
"deranged-macros",
"num-traits",
"powerfmt",
"quickcheck",
"rand 0.10.0",
"rand 0.8.5",
"rand 0.9.0",
"serde_core",
"serde_json",
]
[[package]]
name = "deranged-macros"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8952b6aa444b5338b25807ef3ccfc4082637d28bd77e2305dc60d6cae04af6c1"
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "getrandom"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
dependencies = [
"cfg-if",
"libc",
"wasi 0.13.3+wasi-0.2.2",
"windows-targets",
]
[[package]]
name = "getrandom"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"rand_core 0.10.0",
"wasip2",
"wasip3",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash",
]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "id-arena"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "indexmap"
version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
dependencies = [
"equivalent",
"hashbrown 0.16.1",
"serde",
"serde_core",
]
[[package]]
name = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "leb128fmt"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[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.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "num-traits"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
dependencies = [
"autocfg",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quickcheck"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"rand 0.8.5",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
]
[[package]]
name = "rand"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
dependencies = [
"rand_chacha 0.9.0",
"rand_core 0.9.2",
"zerocopy",
]
[[package]]
name = "rand"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
dependencies = [
"chacha20",
"getrandom 0.4.1",
"rand_core 0.10.0",
]
[[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 0.6.4",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core 0.9.2",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom 0.2.12",
]
[[package]]
name = "rand_core"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c"
dependencies = [
"getrandom 0.3.1",
"zerocopy",
]
[[package]]
name = "rand_core"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
[[package]]
name = "ryu"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "semver"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
[[package]]
name = "serde"
version = "1.0.226"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.226"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.226"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.13.3+wasi-0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
dependencies = [
"wit-bindgen-rt",
]
[[package]]
name = "wasip2"
version = "1.0.2+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasip3"
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasm-encoder"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
dependencies = [
"leb128fmt",
"wasmparser",
]
[[package]]
name = "wasm-metadata"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder",
"wasmparser",
]
[[package]]
name = "wasmparser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
"indexmap",
"semver",
]
[[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 = "wit-bindgen"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
dependencies = [
"wit-bindgen-rust-macro",
]
[[package]]
name = "wit-bindgen-core"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
dependencies = [
"anyhow",
"heck",
"wit-parser",
]
[[package]]
name = "wit-bindgen-rt"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
dependencies = [
"bitflags",
]
[[package]]
name = "wit-bindgen-rust"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
dependencies = [
"anyhow",
"heck",
"indexmap",
"prettyplease",
"syn",
"wasm-metadata",
"wit-bindgen-core",
"wit-component",
]
[[package]]
name = "wit-bindgen-rust-macro"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
dependencies = [
"anyhow",
"prettyplease",
"proc-macro2",
"quote",
"syn",
"wit-bindgen-core",
"wit-bindgen-rust",
]
[[package]]
name = "wit-component"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags",
"indexmap",
"log",
"serde",
"serde_derive",
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser",
"wit-parser",
]
[[package]]
name = "wit-parser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
dependencies = [
"anyhow",
"id-arena",
"indexmap",
"log",
"semver",
"serde",
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser",
]
[[package]]
name = "zerocopy"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

217
vendor/deranged/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,217 @@
# 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.85.0"
name = "deranged"
version = "0.5.8"
authors = ["Jacob Pratt <jacob@jhpratt.dev>"]
build = false
include = [
"src/**/*",
"LICENSE-*",
"README.md",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Ranged integers"
readme = "README.md"
keywords = [
"integer",
"int",
"range",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/jhpratt/deranged"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = [
"--generate-link-to-definition",
"--generate-macro-expansion",
]
[features]
alloc = []
default = []
macros = ["dep:deranged-macros"]
num = ["dep:num-traits"]
powerfmt = ["dep:powerfmt"]
quickcheck = [
"dep:quickcheck",
"alloc",
]
rand = [
"rand08",
"rand09",
"rand010",
]
rand010 = ["dep:rand010"]
rand08 = ["dep:rand08"]
rand09 = ["dep:rand09"]
serde = ["dep:serde_core"]
[lib]
name = "deranged"
path = "src/lib.rs"
[dependencies.deranged-macros]
version = "=0.3.0"
optional = true
[dependencies.num-traits]
version = "0.2.15"
optional = true
default-features = false
[dependencies.powerfmt]
version = "0.2.0"
optional = true
default-features = false
[dependencies.quickcheck]
version = "1.0.3"
optional = true
default-features = false
[dependencies.rand010]
version = "0.10.0"
optional = true
default-features = false
package = "rand"
[dependencies.rand08]
version = "0.8.4"
optional = true
default-features = false
package = "rand"
[dependencies.rand09]
version = "0.9.0"
optional = true
default-features = false
package = "rand"
[dependencies.serde_core]
version = "1.0.220"
optional = true
default-features = false
[dev-dependencies.rand010]
version = "0.10.0"
package = "rand"
[dev-dependencies.rand08]
version = "0.8.4"
package = "rand"
[dev-dependencies.rand09]
version = "0.9.0"
package = "rand"
[dev-dependencies.serde_json]
version = "1.0.86"
[lints.clippy]
alloc-instead-of-core = "deny"
dbg-macro = "warn"
decimal-literal-representation = "warn"
explicit-auto-deref = "warn"
get-unwrap = "warn"
manual-let-else = "warn"
missing-docs-in-private-items = "warn"
missing-enforced-import-renames = "warn"
obfuscated-if-else = "warn"
option-if-let-else = "allow"
print-stdout = "warn"
redundant-pub-crate = "allow"
semicolon-outside-block = "warn"
std-instead-of-core = "deny"
todo = "warn"
undocumented-unsafe-blocks = "deny"
unimplemented = "warn"
uninlined-format-args = "warn"
unnested-or-patterns = "warn"
unwrap-in-result = "warn"
unwrap-used = "warn"
use-debug = "warn"
[lints.clippy.all]
level = "warn"
priority = -1
[lints.clippy.nursery]
level = "warn"
priority = -1
[lints.rust]
ambiguous-glob-reexports = "deny"
clashing-extern-declarations = "deny"
const-item-mutation = "deny"
dangling-pointers-from-temporaries = "deny"
deref-nullptr = "deny"
drop-bounds = "deny"
future-incompatible = "deny"
hidden-glob-reexports = "deny"
improper-ctypes = "deny"
improper-ctypes-definitions = "deny"
invalid-from-utf8 = "deny"
invalid-macro-export-arguments = "deny"
invalid-nan-comparisons = "deny"
invalid-reference-casting = "deny"
invalid-value = "deny"
keyword-idents = "warn"
let-underscore = "warn"
macro-use-extern-crate = "warn"
meta-variable-misuse = "warn"
missing-abi = "warn"
missing-copy-implementations = "warn"
missing-debug-implementations = "warn"
missing-docs = "warn"
named-arguments-used-positionally = "deny"
non-ascii-idents = "deny"
noop-method-call = "warn"
opaque-hidden-inferred-bound = "deny"
overlapping-range-endpoints = "deny"
single-use-lifetimes = "warn"
suspicious-double-ref-op = "deny"
trivial-casts = "warn"
trivial-numeric-casts = "warn"
unconditional-recursion = "deny"
unnameable-test-items = "deny"
unreachable-pub = "warn"
unsafe-op-in-unsafe-fn = "deny"
unstable-syntax-pre-expansion = "deny"
unused-import-braces = "warn"
unused-lifetimes = "warn"
unused-qualifications = "warn"
variant-size-differences = "warn"
[lints.rust.path-statements]
level = "allow"
priority = 1
[lints.rust.unstable-name-collisions]
level = "warn"
priority = 1
[lints.rust.unused]
level = "warn"
priority = -1
[lints.rustdoc]
private-doc-tests = "warn"
unescaped-backticks = "warn"

202
vendor/deranged/LICENSE-Apache vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2024 Jacob Pratt et al.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

19
vendor/deranged/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2024 Jacob Pratt et al.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS 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. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
vendor/deranged/README.md vendored Normal file
View File

@@ -0,0 +1,3 @@
# Deranged
This crate is a proof-of-concept implementation of ranged integers.

2141
vendor/deranged/src/lib.rs vendored Normal file

File diff suppressed because it is too large Load Diff

744
vendor/deranged/src/tests.rs vendored Normal file
View File

@@ -0,0 +1,744 @@
extern crate std;
use core::hash::Hash;
use std::format;
use std::prelude::rust_2021::*;
use crate::{
IntErrorKind, OptionRangedI128, OptionRangedI16, OptionRangedI32, OptionRangedI64,
OptionRangedI8, OptionRangedIsize, OptionRangedU128, OptionRangedU16, OptionRangedU32,
OptionRangedU64, OptionRangedU8, OptionRangedUsize, ParseIntError, RangedI128, RangedI16,
RangedI32, RangedI64, RangedI8, RangedIsize, RangedU128, RangedU16, RangedU32, RangedU64,
RangedU8, RangedUsize, TryFromIntError,
};
#[test]
fn test_ranged_conversion() {
// equal range
let _: RangedI8<-5, 5> = RangedI16::<-5, 5>::new_static::<3>().into();
// wider range
let _: RangedI8<-6, 6> = RangedI16::<-5, 5>::new_static::<3>().into();
// the following fails to compile because the source range is wider than the destination range
// let _ : RangedI8<-4, 4> = RangedI16::<-5, 5>::new_static::<3>().into();
}
macro_rules! if_signed {
(signed $($x:tt)*) => { $($x)* };
(unsigned $($x:tt)*) => {};
}
macro_rules! if_unsigned {
(signed $($x:tt)*) => {};
(unsigned $($x:tt)*) => { $($x)* };
}
#[test]
fn errors() {
assert_eq!(
TryFromIntError.to_string(),
"out of range integral type conversion attempted"
);
assert_eq!(TryFromIntError.clone(), TryFromIntError);
assert_eq!(format!("{TryFromIntError:?}"), "TryFromIntError");
assert_eq!(
ParseIntError {
kind: IntErrorKind::Empty,
}
.to_string(),
"cannot parse integer from empty string"
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::InvalidDigit,
}
.to_string(),
"invalid digit found in string"
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::PosOverflow,
}
.to_string(),
"number too large to fit in target type"
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::NegOverflow,
}
.to_string(),
"number too small to fit in target type"
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::Zero,
}
.to_string(),
"number would be zero for non-zero type"
);
assert_eq!(
format!(
"{:?}",
ParseIntError {
kind: IntErrorKind::Empty
}
),
"ParseIntError { kind: Empty }"
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::Empty
}
.clone(),
ParseIntError {
kind: IntErrorKind::Empty
}
);
assert_eq!(
ParseIntError {
kind: IntErrorKind::Empty
}
.kind(),
&IntErrorKind::Empty
);
}
macro_rules! tests {
($($signed:ident $opt:ident $t:ident $inner:ident),* $(,)?) => {
#[test]
fn derives() {$(
assert_eq!($t::<5, 10>::MIN.clone(), $t::<5, 10>::MIN);
let mut hasher = std::collections::hash_map::DefaultHasher::new();
$t::<5, 10>::MIN.hash(&mut hasher);
assert_eq!(
$t::<5, 10>::MIN.cmp(&$t::<5, 10>::MAX),
core::cmp::Ordering::Less
);
assert_eq!($opt::<5, 10>::None.clone(), $opt::<5, 10>::None);
$opt::<5, 10>::None.hash(&mut hasher);
)*}
#[test]
fn expand() {$(
let expanded: $t::<0, 20> = $t::<5, 10>::MAX.expand();
assert_eq!(expanded, $t::<0, 20>::new_static::<10>());
)*}
#[test]
fn narrow() {$(
let narrowed: Option<$t::<10, 20>> = $t::<0, 20>::new_static::<10>().narrow();
assert_eq!(narrowed, Some($t::<10, 20>::MIN));
)*}
#[test]
fn new() {$(
assert!($t::<5, 10>::new(10).is_some());
assert!($t::<5, 10>::new(11).is_none());
)*}
#[test]
fn new_static() {$(
let six: $t::<5, 10> = $t::<5, 10>::new_static::<6>();
assert_eq!(Some(six), $t::<5, 10>::new(6));
)*}
#[test]
fn some_unchecked() {$(
// Safety: The value is in range.
unsafe {
assert_eq!($opt::<5, 10>::some_unchecked(10), $opt::Some($t::<5, 10>::MAX));
}
)*}
#[test]
fn is_some() {$(
assert!($opt::<5, 10>::Some($t::<5, 10>::MAX).is_some());
)*}
#[test]
fn is_none() {$(
assert!($opt::<5, 10>::None.is_none());
)*}
#[test]
fn is_some_by_ref() {$(
let value = $opt::<5, 10>::Some($t::<5, 10>::MAX);
assert!($opt::is_some(&value));
)*}
#[test]
fn is_none_by_ref() {$(
let value = $opt::<5, 10>::None;
assert!($opt::is_none(&value));
)*}
#[test]
fn default() {$(
assert_eq!($opt::<5, 10>::default(), $opt::<5, 10>::None);
)*}
#[test]
fn get() {$(
assert_eq!($t::<5, 10>::MAX.get(), 10);
assert_eq!($opt::<5, 10>::None.get(), None);
assert_eq!($opt::Some($t::<5, 10>::MAX).get(), Some($t::<5, 10>::MAX));
)*}
#[test]
fn get_primitive() {$(
assert_eq!($opt::Some($t::<5, 10>::MAX).get_primitive(), Some(10));
assert_eq!($opt::<5, 10>::None.get_primitive(), None);
)*}
#[test]
fn get_ref() {$(
assert_eq!($t::<5, 10>::MAX.get_ref(), &10);
)*}
#[test]
fn new_saturating() {$(
assert_eq!($t::<5, 10>::new_saturating(11), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::new_saturating(0), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::new_saturating(9), $t::<5, 10>::new_static::<9>());
)*}
#[test]
fn from_str_radix() {$(
assert_eq!($t::<5, 10>::from_str_radix("10", 10), Ok($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::from_str_radix("5", 10), Ok($t::<5, 10>::MIN));
assert_eq!(
$t::<5, 10>::from_str_radix("4", 10),
Err(ParseIntError { kind: IntErrorKind::NegOverflow }),
);
assert_eq!(
$t::<5, 10>::from_str_radix("11", 10),
Err(ParseIntError { kind: IntErrorKind::PosOverflow }),
);
assert_eq!(
$t::<5, 10>::from_str_radix("", 10),
Err(ParseIntError { kind: IntErrorKind::Empty }),
);
)*}
#[test]
fn checked_add() {$(
assert_eq!($t::<5, 10>::MAX.checked_add(1), None);
assert_eq!($t::<5, 10>::MAX.checked_add(0), Some($t::<5, 10>::MAX));
)*}
#[test]
fn unchecked_add() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MIN.unchecked_add(5), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_sub() {$(
assert_eq!($t::<5, 10>::MIN.checked_sub(1), None);
assert_eq!($t::<5, 10>::MIN.checked_sub(0), Some($t::<5, 10>::MIN));
)*}
#[test]
fn unchecked_sub() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_sub(5), $t::<5, 10>::MIN);
}
)*}
#[test]
fn checked_mul() {$(
assert_eq!($t::<5, 10>::MAX.checked_mul(2), None);
assert_eq!($t::<5, 10>::MAX.checked_mul(1), Some($t::<5, 10>::MAX));
)*}
#[test]
fn unchecked_mul() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_mul(1), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_div() {$(
assert_eq!($t::<5, 10>::MAX.checked_div(3), None);
assert_eq!($t::<5, 10>::MAX.checked_div(2), $t::<5, 10>::new(5));
assert_eq!($t::<5, 10>::MAX.checked_div(1), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MAX.checked_div(0), None);
)*}
#[test]
fn unchecked_div() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_div(1), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_div_euclid() {$(
assert_eq!($t::<5, 10>::MAX.checked_div_euclid(3), None);
assert_eq!($t::<5, 10>::MAX.checked_div_euclid(2), $t::<5, 10>::new(5));
assert_eq!($t::<5, 10>::MAX.checked_div_euclid(1), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MAX.checked_div_euclid(0), None);
)*}
#[test]
fn unchecked_div_euclid() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_div_euclid(1), $t::<5, 10>::MAX);
}
)*}
#[test]
fn rem() {$(if_unsigned! { $signed
assert_eq!($t::<5, 10>::MAX.rem($t::exact::<3>()), $t::<0, 3>::new_static::<1>());
assert_eq!($t::<5, 10>::MAX.rem($t::exact::<5>()), $t::<0, 5>::MIN);
})*}
#[test]
fn checked_rem() {$(
assert_eq!($t::<5, 10>::MAX.checked_rem(11), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MAX.checked_rem(5), None);
)*}
#[test]
fn unchecked_rem() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_rem(11), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_rem_euclid() {$(
assert_eq!($t::<5, 10>::MAX.checked_rem_euclid(11), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MAX.checked_rem_euclid(5), None);
)*}
#[test]
fn unchecked_rem_euclid() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_rem_euclid(11), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_neg() {$(
assert_eq!($t::<5, 10>::MIN.checked_neg(), None);
assert_eq!($t::<0, 10>::MIN.checked_neg(), Some($t::<0, 10>::MIN));
)*}
#[test]
fn unchecked_neg() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<0, 10>::MIN.unchecked_neg(), $t::<0, 10>::MIN);
}
)*}
#[test]
fn neg() {$( if_signed! { $signed
assert_eq!($t::<-10, 10>::MIN.neg(), $t::<-10, 10>::MAX);
})*}
#[test]
fn checked_shl() {$(
assert_eq!($t::<5, 10>::MAX.checked_shl(1), None);
assert_eq!($t::<5, 10>::MAX.checked_shl(0), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MIN.checked_shl(1), Some($t::<5, 10>::MAX));
)*}
#[test]
fn unchecked_shl() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_shl(0), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::MIN.unchecked_shl(1), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_shr() {$(
assert_eq!($t::<5, 10>::MAX.checked_shr(2), None);
assert_eq!($t::<5, 10>::MAX.checked_shr(1), Some($t::<5, 10>::MIN));
assert_eq!($t::<5, 10>::MAX.checked_shr(0), Some($t::<5, 10>::MAX));
)*}
#[test]
fn unchecked_shr() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_shr(1), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MAX.unchecked_shr(0), $t::<5, 10>::MAX);
}
)*}
#[test]
fn checked_abs() {$( if_signed! { $signed
assert_eq!($t::<5, 10>::MAX.checked_abs(), Some($t::<5, 10>::MAX));
assert_eq!($t::<-10, 10>::MIN.checked_abs(), Some($t::<-10, 10>::MAX));
assert_eq!($t::<-10, 0>::MIN.checked_abs(), None);
})*}
#[test]
fn unchecked_abs() { $(if_signed! { $signed
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_abs(), $t::<5, 10>::MAX);
assert_eq!($t::<-10, 10>::MIN.unchecked_abs(), $t::<-10, 10>::MAX);
}
})*}
#[test]
fn abs() { $(if_signed! { $signed
assert_eq!($t::<-5, 10>::MIN.abs().get(), 5);
})*}
#[test]
fn checked_pow() {$(
assert_eq!($t::<5, 10>::MAX.checked_pow(0), None);
assert_eq!($t::<5, 10>::MAX.checked_pow(1), Some($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::MAX.checked_pow(2), None);
)*}
#[test]
fn unchecked_pow() {$(
// Safety: The result is in range.
unsafe {
assert_eq!($t::<5, 10>::MAX.unchecked_pow(1), $t::<5, 10>::MAX);
}
)*}
#[test]
fn saturating_add() {$(
assert_eq!($t::<5, 10>::MAX.saturating_add(0), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::MAX.saturating_add(1), $t::<5, 10>::MAX);
)*}
#[test]
fn wrapping_add() {
$(
assert_eq!($t::<5, 10>::MAX.wrapping_add(0), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::MAX.wrapping_add(1), $t::<5, 10>::MIN);
assert_eq!($t::<{ $inner::MIN }, { $inner::MAX }>::MAX.wrapping_add(1),
$t::<{ $inner::MIN }, { $inner::MAX }>::MIN);
for i in 1..127 {
assert_eq!(
$t::<{ $inner::MIN}, { $inner::MAX - 1 }>::MAX.wrapping_add(i),
$t::<{ $inner::MIN}, { $inner::MAX - 1 }>::new($inner::MIN + i - 1).unwrap_or_else(|| panic!("adding {i}+{} does not yield {}", $inner::MIN, $inner::MAX + i ))
);
}
)*
$(if_signed! { $signed
for i in 1..=127 {
assert_eq!($t::<-5, 126>::MIN.wrapping_add(-i), $t::<-5,126>::new(126-i+1).unwrap_or_else(|| panic!("adding {i}+{} does not yield {}", $inner::MIN, 126-i+1)));
assert_eq!($t::<-5, 126>::MIN.wrapping_add(i), $t::<-5,126>::new(-5+i).unwrap_or_else(|| panic!("adding {i}+{} does not yield {}", $inner::MIN, 126-i+1)));
}
for i in -127..=-1 {
assert_eq!($t::<-5, 126>::MIN.wrapping_add(i), $t::<-5,126>::new(126+i+1).unwrap_or_else(|| panic!("adding {i}+{} does not yield {}", $inner::MIN, 126-i+1)));
assert_eq!($t::<-5, 126>::MIN.wrapping_add(-i), $t::<-5,126>::new(-5-i).unwrap_or_else(|| panic!("adding {i}+{} does not yield {}", $inner::MIN, 126-i+1)));
}
assert_eq!($t::<-5, 126>::MIN.wrapping_add(-128), $t::<-5,126>::new(-1).unwrap_or_else(|| panic!("adding 128+{} does not yield -1", $inner::MIN)));
assert_eq!($t::<-5, 10>::MAX.wrapping_add(0), $t::<-5, 10>::MAX);
assert_eq!($t::<-5, -3>::MIN.wrapping_add(-1-3), $t::<-5, -3>::MAX);
assert_eq!($t::<-5, -3>::MIN.wrapping_add(-1-30), $t::<-5, -3>::MAX);
assert_eq!($t::<-5, -3>::MIN.wrapping_add(30), $t::<-5, -3>::MIN);
assert_eq!($t::<-5, -3>::MIN.wrapping_add(-30), $t::<-5, -3>::MIN);
assert_eq!($t::<-5, 10>::MAX.wrapping_add(25), $t::<-5, 10>::MIN.wrapping_add(24));
assert_eq!($t::<-5, 10>::MIN.wrapping_add(24), $t::<-5, 10>::MIN.wrapping_add(8));
assert_eq!($t::<-5, 10>::MAX.wrapping_add(1), $t::<-5, 10>::MIN);
assert_eq!($t::<-5, 10>::MIN.wrapping_add(-1), $t::<-5, 10>::MAX);
assert_eq!($t::<-5, 127>::MIN.wrapping_add(-1), $t::<-5, 127>::MAX);
assert_eq!($t::<-127, 126>::MIN.wrapping_add(-1), $t::<-127, 126>::MAX);
assert_eq!($t::<{ $inner::MIN }, { $inner::MAX }>::MIN.wrapping_add(-1),
$t::<{ $inner::MIN }, { $inner::MAX }>::MAX);
})*
}
#[test]
fn wrapping_sub() {
$(
assert_eq!($t::<5, 10>::MIN.wrapping_sub(0), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.wrapping_sub(1), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::new(5 + 1).unwrap().wrapping_sub(1), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MAX.wrapping_sub(1), $t::<5, 10>::new(10 - 1).unwrap());
assert_eq!($t::<{ $inner::MIN }, { $inner::MAX }>::MIN.wrapping_sub(1),
$t::<{ $inner::MIN }, { $inner::MAX }>::MAX);
for i in 1..127 {
assert_eq!(
$t::<{ $inner::MIN + 1 }, { $inner::MAX }>::MIN.wrapping_sub(i),
$t::<{ $inner::MIN + 1 }, { $inner::MAX }>::new($inner::MAX - i + 1).unwrap_or_else(|| panic!("failed test at iteration {i}"))
);
}
)*
$(if_signed! { $signed
for i in -127..=127 {
assert_eq!($t::<-5, 126>::MIN.wrapping_add(i), $t::<-5,126>::MIN.wrapping_sub(-i), "failed test at {i}");
assert_eq!($t::<-5, 126>::MIN.wrapping_add(-i), $t::<-5,126>::MIN.wrapping_sub(i), "failed test at {i}");
}
assert_eq!(
$t::<-5, 126>::MIN.wrapping_add(127).wrapping_add(1),
$t::<-5,126>::MIN.wrapping_sub(-128)
);
assert_eq!(
$t::<-5, 126>::MIN.wrapping_add(-128),
$t::<-5,126>::MIN.wrapping_sub(127).wrapping_sub(1)
);
})*
}
#[test]
fn saturating_sub() {$(
assert_eq!($t::<5, 10>::MIN.saturating_sub(0), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.saturating_sub(1), $t::<5, 10>::MIN);
)*}
#[test]
fn saturating_neg() {$(if_signed! { $signed
assert_eq!($t::<5, 10>::MIN.saturating_neg(), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MAX.saturating_neg(), $t::<5, 10>::MIN);
assert_eq!($t::<-10, 0>::MIN.saturating_neg(), $t::<-10, 0>::MAX);
assert_eq!($t::<-10, 0>::MAX.saturating_neg(), $t::<-10, 0>::MAX);
})*}
#[test]
fn saturating_abs() {$(if_signed! { $signed
assert_eq!($t::<5, 10>::MIN.saturating_abs(), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MAX.saturating_abs(), $t::<5, 10>::MAX);
assert_eq!($t::<-10, 0>::MIN.saturating_abs(), $t::<-10, 0>::MAX);
assert_eq!($t::<-10, 0>::MAX.saturating_abs(), $t::<-10, 0>::MAX);
})*}
#[test]
fn saturating_mul() {$(
assert_eq!($t::<5, 10>::MIN.saturating_mul(0), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.saturating_mul(1), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.saturating_mul(2), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::MIN.saturating_mul(3), $t::<5, 10>::MAX);
)*}
#[test]
fn saturating_pow() {$(
assert_eq!($t::<5, 10>::MIN.saturating_pow(0), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.saturating_pow(1), $t::<5, 10>::MIN);
assert_eq!($t::<5, 10>::MIN.saturating_pow(2), $t::<5, 10>::MAX);
assert_eq!($t::<5, 10>::MIN.saturating_pow(3), $t::<5, 10>::MAX);
)*}
#[test]
fn as_ref() {$(
assert_eq!($t::<5, 10>::MIN.as_ref(), &5);
assert_eq!($t::<5, 10>::MAX.as_ref(), &10);
)*}
#[test]
fn borrow() {
use core::borrow::Borrow;
$(
assert_eq!(Borrow::<$inner>::borrow(&$t::<5, 10>::MIN), &5);
assert_eq!(Borrow::<$inner>::borrow(&$t::<5, 10>::MAX), &10);
)*
}
#[test]
fn formatting() {$(
let val = $t::<5, 10>::MAX;
assert_eq!(format!("{}", val), "10");
assert_eq!(format!("{:?}", val), "10");
assert_eq!(format!("{:b}", val), "1010");
assert_eq!(format!("{:o}", val), "12");
assert_eq!(format!("{:x}", val), "a");
assert_eq!(format!("{:X}", val), "A");
assert_eq!(format!("{:e}", val), "1e1");
assert_eq!(format!("{:E}", val), "1E1");
assert_eq!(format!("{:?}", $opt::Some($t::<5, 10>::MAX)), "Some(10)");
assert_eq!(format!("{:?}", $opt::<5, 10>::None), "None");
)*}
#[test]
fn ord() {$(
assert!($t::<5, 10>::MIN < $t::<5, 10>::MAX);
assert!($t::<5, 10>::MIN <= $t::<5, 10>::MAX);
assert!($t::<5, 10>::MAX > $t::<5, 10>::MIN);
assert!($t::<5, 10>::MAX >= $t::<5, 10>::MIN);
let none = $opt::<5, 10>::None;
let five = $opt::Some($t::<5, 10>::MIN);
let ten = $opt::Some($t::<5, 10>::MAX);
assert_eq!(none.cmp(&none), core::cmp::Ordering::Equal);
assert_eq!(five.cmp(&five), core::cmp::Ordering::Equal);
assert_eq!(ten.cmp(&ten), core::cmp::Ordering::Equal);
assert_eq!(none.cmp(&five), core::cmp::Ordering::Less);
assert_eq!(five.cmp(&ten), core::cmp::Ordering::Less);
assert_eq!(none.cmp(&ten), core::cmp::Ordering::Less);
assert_eq!(ten.cmp(&none), core::cmp::Ordering::Greater);
let none = $opt::<0, 10>::None;
let zero = $opt::Some($t::<0, 10>::MIN);
let ten = $opt::Some($t::<0, 10>::MAX);
assert_eq!(none.partial_cmp(&none), Some(core::cmp::Ordering::Equal));
assert_eq!(none.partial_cmp(&zero), Some(core::cmp::Ordering::Less));
assert_eq!(zero.partial_cmp(&ten), Some(core::cmp::Ordering::Less));
assert_eq!(none.partial_cmp(&ten), Some(core::cmp::Ordering::Less));
assert_eq!(ten.partial_cmp(&none), Some(core::cmp::Ordering::Greater));
)*}
#[test]
fn from() {$(
assert_eq!($inner::from($t::<5, 10>::MAX), 10);
assert_eq!($inner::from($t::<5, 10>::MIN), 5);
assert_eq!($opt::from($t::<5, 10>::MAX), $opt::Some($t::<5, 10>::MAX));
assert_eq!($opt::from(Some($t::<5, 10>::MAX)), $opt::Some($t::<5, 10>::MAX));
assert_eq!($opt::<5, 10>::from(None), $opt::<5, 10>::None);
assert_eq!(Option::from($opt::Some($t::<5, 10>::MAX)), Some($t::<5, 10>::MAX));
assert_eq!(Option::<$t<5, 10>>::from($opt::<5, 10>::None), None);
)*}
#[test]
fn try_from() {$(
assert_eq!($t::<5, 10>::try_from(10), Ok($t::<5, 10>::MAX));
assert_eq!($t::<5, 10>::try_from(5), Ok($t::<5, 10>::MIN));
assert_eq!($t::<5, 10>::try_from(4), Err(TryFromIntError));
assert_eq!($t::<5, 10>::try_from(11), Err(TryFromIntError));
)*}
#[test]
fn from_str() {$(
assert_eq!("10".parse::<$t<5, 10>>(), Ok($t::<5, 10>::MAX));
assert_eq!("5".parse::<$t<5, 10>>(), Ok($t::<5, 10>::MIN));
assert_eq!("4".parse::<$t<5, 10>>(), Err(ParseIntError { kind: IntErrorKind::NegOverflow }));
assert_eq!("11".parse::<$t<5, 10>>(), Err(ParseIntError { kind: IntErrorKind::PosOverflow }));
assert_eq!("".parse::<$t<5, 10>>(), Err(ParseIntError { kind: IntErrorKind::Empty }));
)*}
#[cfg(feature = "serde")]
#[test]
fn serde() -> serde_json::Result<()> {
$(
let val = $t::<5, 10>::MAX;
let serialized = serde_json::to_string(&val)?;
assert_eq!(serialized, "10");
let deserialized: $t<5, 10> = serde_json::from_str(&serialized)?;
assert_eq!(deserialized, val);
assert!(serde_json::from_str::<$t<5, 10>>("").is_err());
assert!(serde_json::from_str::<$t<5, 10>>("4").is_err());
assert!(serde_json::from_str::<$t<5, 10>>("11").is_err());
let val = $opt::<5, 10>::Some($t::<5, 10>::MAX);
let serialized = serde_json::to_string(&val)?;
assert_eq!(serialized, "10");
let deserialized: $opt<5, 10> = serde_json::from_str(&serialized)?;
assert_eq!(deserialized, val);
assert!(serde_json::from_str::<$opt<5, 10>>("").is_err());
assert!(serde_json::from_str::<$opt<5, 10>>("4").is_err());
assert!(serde_json::from_str::<$opt<5, 10>>("11").is_err());
let val = $opt::<5, 10>::None;
let serialized = serde_json::to_string(&val)?;
assert_eq!(serialized, "null");
assert!(serde_json::from_str::<$opt<5, 10>>("").is_err());
assert!(serde_json::from_str::<$opt<5, 10>>("4").is_err());
assert!(serde_json::from_str::<$opt<5, 10>>("11").is_err());
)*
Ok(())
}
#[cfg(feature = "rand08")]
#[test]
fn rand08() {$(
let rand_val: $t<5, 10> = rand08::random();
assert!(rand_val >= $t::<5, 10>::MIN);
assert!(rand_val <= $t::<5, 10>::MAX);
let rand: $opt<5, 10> = rand08::random();
if let Some(rand) = rand.get() {
assert!(rand >= $t::<5, 10>::MIN);
assert!(rand <= $t::<5, 10>::MAX);
}
)*}
#[cfg(feature = "rand09")]
#[test]
fn rand09() {$(
let rand_val: $t<5, 10> = rand09::random();
assert!(rand_val >= $t::<5, 10>::MIN);
assert!(rand_val <= $t::<5, 10>::MAX);
let rand: $opt<5, 10> = rand09::random();
if let Some(rand) = rand.get() {
assert!(rand >= $t::<5, 10>::MIN);
assert!(rand <= $t::<5, 10>::MAX);
}
)*}
#[cfg(feature = "rand010")]
#[test]
fn rand010() {$(
let rand_val: $t<5, 10> = rand010::random();
assert!(rand_val >= $t::<5, 10>::MIN);
assert!(rand_val <= $t::<5, 10>::MAX);
let rand: $opt<5, 10> = rand010::random();
if let Some(rand) = rand.get() {
assert!(rand >= $t::<5, 10>::MIN);
assert!(rand <= $t::<5, 10>::MAX);
}
)*}
#[cfg(feature = "num")]
#[test]
fn num() {$(
assert_eq!(<$t<5, 10> as num_traits::Bounded>::min_value(), $t::<5, 10>::MIN);
assert_eq!(<$t<5, 10> as num_traits::Bounded>::max_value(), $t::<5, 10>::MAX);
)*}
#[cfg(feature = "quickcheck")]
#[test]
fn quickcheck() {$(
#[allow(trivial_casts)]
quickcheck::quickcheck((|val| {
val >= $t::<5, 10>::MIN && val <= $t::<5, 10>::MAX
}) as fn($t<5, 10>) -> bool);
#[allow(trivial_casts)]
quickcheck::quickcheck((|val| {
if let Some(val) = val.get() {
val >= $t::<5, 10>::MIN && val <= $t::<5, 10>::MAX
} else {
true
}
}) as fn($opt<5, 10>) -> bool);
)*}
};
}
tests![
signed OptionRangedI8 RangedI8 i8,
signed OptionRangedI16 RangedI16 i16,
signed OptionRangedI32 RangedI32 i32,
signed OptionRangedI64 RangedI64 i64,
signed OptionRangedI128 RangedI128 i128,
signed OptionRangedIsize RangedIsize isize,
unsigned OptionRangedU8 RangedU8 u8,
unsigned OptionRangedU16 RangedU16 u16,
unsigned OptionRangedU32 RangedU32 u32,
unsigned OptionRangedU64 RangedU64 u64,
unsigned OptionRangedU128 RangedU128 u128,
unsigned OptionRangedUsize RangedUsize usize,
];

36
vendor/deranged/src/unsafe_wrapper.rs vendored Normal file
View File

@@ -0,0 +1,36 @@
//! Declaration and implementation of `Unsafe`, which ensures all unsafe operations are correctly
//! placed in unsafe blocks.
/// A value that is safe to use, but is unsafe to construct or mutate.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct Unsafe<T>(T);
impl<T: core::fmt::Debug> core::fmt::Debug for Unsafe<T> {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.0.fmt(f)
}
}
impl<T> Unsafe<T> {
/// Create a new `Unsafe`, asserting that all invariants are upheld.
#[inline(always)]
pub(crate) const unsafe fn new(value: T) -> Self {
Self(value)
}
/// Get a reference to the inner value.
#[inline(always)]
pub(crate) const fn get(&self) -> &T {
&self.0
}
}
impl<T> core::ops::Deref for Unsafe<T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}