diff --git a/Cargo.lock b/Cargo.lock index 0b6a55dc..7254f69a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "parking_lot", "pem-rfc7468", "pkcs8 0.10.2", - "rand", + "rand 0.8.5", "reqwest", "serde", "serde_json", @@ -182,7 +182,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand", + "rand 0.8.5", "sha1", "smallvec", "tokio", @@ -218,15 +218,15 @@ dependencies = [ [[package]] name = "actix-identity" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c99b7a5614b72a78f04aa2021e5370fc1aef2475fffeffc0c1266b99007062" +checksum = "23b8ddc6f6a8b19c4016aaa13519968da9969bc3bc1c1c883cdb0f25dd6c8cf7" dependencies = [ "actix-service", - "actix-session 0.9.0", + "actix-session", "actix-utils", "actix-web", - "derive_more 0.99.18", + "derive_more 1.0.0", "futures-core", "serde", "tracing", @@ -259,7 +259,7 @@ dependencies = [ "log", "memchr", "mime", - "rand", + "rand 0.8.5", "serde", "serde_json", "serde_plain", @@ -346,22 +346,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "actix-session" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b671404ec72194d8af58c2bdaf51e3c477a0595056bd5010148405870dda8df2" -dependencies = [ - "actix-service", - "actix-utils", - "actix-web", - "anyhow", - "derive_more 0.99.18", - "serde", - "serde_json", - "tracing", -] - [[package]] name = "actix-session" version = "0.10.1" @@ -373,7 +357,7 @@ dependencies = [ "actix-web", "anyhow", "derive_more 1.0.0", - "rand", + "rand 0.8.5", "redis 0.26.1", "serde", "serde_json", @@ -511,9 +495,9 @@ dependencies = [ [[package]] name = "actix-web-lab" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a965e3e826aa4737af33666aa09ed949aa1837706fda2adee07039347be50d6" +checksum = "ee75923689132fc5fb57ccc5bb98d25bb214796a29cd505844eb3b42daf11df0" dependencies = [ "actix-http", "actix-router", @@ -536,7 +520,6 @@ dependencies = [ "local-channel", "mediatype", "mime", - "once_cell", "pin-project-lite", "regex", "serde", @@ -550,9 +533,9 @@ dependencies = [ [[package]] name = "actix-web-lab-derive" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008f98f5a68eeacf5e6d44ed74ce03c1b906baa53eabfb41faf0f5f40bd685f8" +checksum = "4c221da13534b9352f3f79fcbbd6095f6d8aee63bdf1da8a73d36f9eeea17d5a" dependencies = [ "proc-macro2", "quote", @@ -661,7 +644,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", ] @@ -674,10 +657,10 @@ checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "const-random", - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -1125,7 +1108,7 @@ dependencies = [ "openssl", "percent-encoding", "pin-project-lite", - "rand", + "rand 0.8.5", "rustls 0.23.23", "serde", "serde_json", @@ -1604,7 +1587,7 @@ dependencies = [ "env_logger", "eyre", "log", - "rand", + "rand 0.9.0", "serde", "tokio", "tokio-util", @@ -1700,7 +1683,7 @@ name = "basics" version = "1.0.0" dependencies = [ "actix-files", - "actix-session 0.10.1", + "actix-session", "actix-web", "actix-web-lab", "async-stream", @@ -1887,7 +1870,7 @@ dependencies = [ "indexmap 2.7.0", "js-sys", "once_cell", - "rand", + "rand 0.8.5", "serde", "serde_bytes", "serde_json", @@ -1987,7 +1970,7 @@ checksum = "a100183440478aa2b64e6f432295fa90c052d53011c9799b655b7283b6e6707c" dependencies = [ "async-trait", "fixedbitset", - "getrandom", + "getrandom 0.2.15", "hashlink 0.9.1", "once_cell", "parking_lot", @@ -2258,7 +2241,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom", + "getrandom 0.2.15", "once_cell", "tiny-keccak", ] @@ -2286,7 +2269,7 @@ dependencies = [ "hkdf", "hmac", "percent-encoding", - "rand", + "rand 0.8.5", "sha2", "subtle", "time", @@ -2298,7 +2281,7 @@ name = "cookie-auth" version = "1.0.0" dependencies = [ "actix-identity", - "actix-session 0.10.1", + "actix-session", "actix-web", "env_logger", "log", @@ -2308,7 +2291,7 @@ dependencies = [ name = "cookie-session" version = "1.0.0" dependencies = [ - "actix-session 0.10.1", + "actix-session", "actix-web", "env_logger", "log", @@ -2452,7 +2435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -2464,7 +2447,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -2476,7 +2459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -2932,7 +2915,7 @@ dependencies = [ "generic-array", "group 0.12.1", "pkcs8 0.9.0", - "rand_core", + "rand_core 0.6.4", "sec1 0.3.0", "subtle", "zeroize", @@ -2952,7 +2935,7 @@ dependencies = [ "group 0.13.0", "pem-rfc7468", "pkcs8 0.10.2", - "rand_core", + "rand_core 0.6.4", "sec1 0.7.3", "subtle", "zeroize", @@ -3036,7 +3019,7 @@ dependencies = [ "derive_more 0.99.18", "env_logger", "log", - "rand", + "rand 0.9.0", ] [[package]] @@ -3093,7 +3076,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -3103,7 +3086,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -3503,10 +3486,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[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 0.52.6", +] + [[package]] name = "ghash" version = "0.5.1" @@ -3568,7 +3563,7 @@ dependencies = [ "parking_lot", "portable-atomic", "quanta", - "rand", + "rand 0.8.5", "smallvec", "spinning_top", ] @@ -3580,7 +3575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff 0.12.1", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -3591,7 +3586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.0", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -3778,7 +3773,7 @@ dependencies = [ "idna 1.0.3", "ipnet", "once_cell", - "rand", + "rand 0.8.5", "thiserror 1.0.69", "tinyvec", "tokio", @@ -3799,7 +3794,7 @@ dependencies = [ "lru-cache", "once_cell", "parking_lot", - "rand", + "rand 0.8.5", "resolv-conf", "smallvec", "thiserror 1.0.69", @@ -5109,7 +5104,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -5121,7 +5116,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -5152,7 +5147,7 @@ dependencies = [ "once_cell", "pbkdf2", "percent-encoding", - "rand", + "rand 0.8.5", "rustc_version_runtime", "rustls 0.21.12", "rustls-pemfile 1.0.4", @@ -5322,7 +5317,7 @@ dependencies = [ "mysql-common-derive", "num-bigint", "num-traits", - "rand", + "rand 0.8.5", "regex", "rust_decimal", "saturating", @@ -5483,7 +5478,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand", + "rand 0.8.5", "smallvec", "zeroize", ] @@ -5662,7 +5657,7 @@ dependencies = [ "opentelemetry", "ordered-float", "percent-encoding", - "rand", + "rand 0.8.5", "thiserror 1.0.69", "tokio", "tokio-stream", @@ -5896,7 +5891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared 0.10.0", - "rand", + "rand 0.8.5", ] [[package]] @@ -5906,7 +5901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand", + "rand 0.8.5", ] [[package]] @@ -6027,7 +6022,7 @@ dependencies = [ "hmac", "md-5", "memchr", - "rand", + "rand 0.8.5", "sha2", "stringprep", ] @@ -6055,7 +6050,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -6247,7 +6242,7 @@ dependencies = [ "libc", "once_cell", "raw-cpuid", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "web-sys", "winapi", ] @@ -6283,8 +6278,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", - "getrandom", - "rand", + "getrandom 0.2.15", + "rand 0.8.5", "ring", "rustc-hash 2.1.0", "rustls 0.23.23", @@ -6368,8 +6363,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "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 0.8.20", ] [[package]] @@ -6379,7 +6385,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "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]] @@ -6388,7 +6404,17 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", +] + +[[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 0.8.20", ] [[package]] @@ -6453,7 +6479,7 @@ dependencies = [ name = "redis-session-example" version = "1.0.0" dependencies = [ - "actix-session 0.10.1", + "actix-session", "actix-test", "actix-web", "env_logger", @@ -6652,7 +6678,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin 0.9.8", "untrusted", @@ -6701,7 +6727,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8 0.10.2", - "rand_core", + "rand_core 0.6.4", "signature 2.2.0", "spki 0.7.3", "subtle", @@ -6738,7 +6764,7 @@ dependencies = [ "borsh", "bytes", "num-traits", - "rand", + "rand 0.8.5", "rkyv", "serde", "serde_json", @@ -7341,7 +7367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -7351,7 +7377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -7365,7 +7391,7 @@ name = "simple-auth-server" version = "1.0.0" dependencies = [ "actix-identity", - "actix-session 0.10.1", + "actix-session", "actix-web", "chrono", "derive_more 0.99.18", @@ -7633,7 +7659,7 @@ dependencies = [ "memchr", "once_cell", "percent-encoding", - "rand", + "rand 0.8.5", "rsa", "serde", "sha1", @@ -7672,7 +7698,7 @@ dependencies = [ "md-5", "memchr", "once_cell", - "rand", + "rand 0.8.5", "serde", "serde_json", "sha2", @@ -8048,7 +8074,7 @@ dependencies = [ "percent-encoding", "pest", "pest_derive", - "rand", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -8251,7 +8277,7 @@ name = "todo" version = "1.0.0" dependencies = [ "actix-files", - "actix-session 0.10.1", + "actix-session", "actix-web", "dotenvy", "env_logger", @@ -8360,7 +8386,7 @@ dependencies = [ "pin-project-lite", "postgres-protocol", "postgres-types", - "rand", + "rand 0.8.5", "socket2", "tokio", "tokio-util", @@ -8374,7 +8400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ "pin-project", - "rand", + "rand 0.8.5", "tokio", ] @@ -8531,7 +8557,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand", + "rand 0.8.5", "slab", "tokio", "tokio-util", @@ -8757,7 +8783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "rand", + "rand 0.8.5", "static_assertions", ] @@ -8799,8 +8825,8 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f903f293d11f31c0c29e4148f6dc0d033a7f80cebc0282bea147611667d289" dependencies = [ - "getrandom", - "rand", + "getrandom 0.2.15", + "rand 0.8.5", "web-time", ] @@ -9026,7 +9052,7 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" dependencies = [ - "getrandom", + "getrandom 0.2.15", "serde", ] @@ -9128,6 +9154,15 @@ 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 = "wasite" version = "0.1.0" @@ -9314,7 +9349,7 @@ dependencies = [ "env_logger", "futures-util", "log", - "rand", + "rand 0.9.0", "tokio", ] @@ -9329,7 +9364,7 @@ dependencies = [ "actix-web-actors", "env_logger", "log", - "rand", + "rand 0.9.0", ] [[package]] @@ -9342,7 +9377,7 @@ dependencies = [ "actix-web-actors", "env_logger", "log", - "rand", + "rand 0.9.0", ] [[package]] @@ -9358,7 +9393,7 @@ dependencies = [ "env_logger", "futures-util", "log", - "rand", + "rand 0.9.0", "serde", "serde_json", "tokio", @@ -9656,6 +9691,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "write16" version = "1.0.0" @@ -9856,7 +9900,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" +dependencies = [ + "zerocopy-derive 0.8.20", ] [[package]] @@ -9870,6 +9923,17 @@ dependencies = [ "syn 2.0.93", ] +[[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 2.0.93", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index 509928b0..8a1e25ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ actix-codec = "0.5" actix-cors = "0.7" actix-files = "0.6" actix-http = "3.5" -actix-identity = "0.7" +actix-identity = "0.8" actix-multipart = "0.7" actix-protobuf = "0.11" actix-session = "0.10" @@ -93,7 +93,7 @@ actix-tls = "3.4" actix-utils = "3" actix-web = "4.9" actix-web-actors = "4.1" -actix-web-lab = "0.22" +actix-web-lab = "0.23" actix-ws = "0.3" awc = "3.2" @@ -108,7 +108,7 @@ log = "0.4" openssl = { version = "0.10.60", features = ["v110"] } parking_lot = "0.12" pin-project-lite = "0.2" -rand = "0.8" +rand = "0.9" redis = { version = "0.27" } reqwest = { version = "0.12", features = ["json", "stream"] } rustls = "0.23" diff --git a/background-jobs/src/persistent_jobs.rs b/background-jobs/src/persistent_jobs.rs index 0e546c68..71f436ce 100644 --- a/background-jobs/src/persistent_jobs.rs +++ b/background-jobs/src/persistent_jobs.rs @@ -4,7 +4,7 @@ use std::time::Duration; use apalis::prelude::*; use apalis_redis::{Config, RedisStorage}; -use rand::distributions::{Alphanumeric, DistString as _}; +use rand::distr::{Alphanumeric, SampleString as _}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] @@ -14,7 +14,7 @@ pub(crate) struct Email { impl Email { pub(crate) fn random() -> Self { - let user = Alphanumeric.sample_string(&mut rand::thread_rng(), 10); + let user = Alphanumeric.sample_string(&mut rand::rng(), 10); let to = format!("{user}@fake-mail.com"); Self { to } } diff --git a/basics/error-handling/src/main.rs b/basics/error-handling/src/main.rs index 2b7c70d7..fda0b2f3 100644 --- a/basics/error-handling/src/main.rs +++ b/basics/error-handling/src/main.rs @@ -15,8 +15,8 @@ http errors will be chosen, each with an equal chance of being selected: use actix_web::{web, App, Error, HttpResponse, HttpServer, ResponseError}; use derive_more::Display; // naming it clearly for illustration purposes use rand::{ - distributions::{Distribution, Standard}, - thread_rng, Rng, + distr::{Distribution, StandardUniform}, + Rng, }; #[derive(Debug, Display)] @@ -31,9 +31,9 @@ pub enum CustomError { CustomFour, } -impl Distribution for Standard { +impl Distribution for StandardUniform { fn sample(&self, rng: &mut R) -> CustomError { - match rng.gen_range(0..4) { + match rng.random_range(0..4) { 0 => CustomError::CustomOne, 1 => CustomError::CustomTwo, 2 => CustomError::CustomThree, @@ -71,10 +71,10 @@ impl ResponseError for CustomError { /// randomly returns either () or one of the 4 CustomError variants async fn do_something_random() -> Result<(), CustomError> { - let mut rng = thread_rng(); + let mut rng = rand::rng(); // 20% chance that () will be returned by this function - if rng.gen_bool(2.0 / 10.0) { + if rng.random_bool(2.0 / 10.0) { Ok(()) } else { Err(rand::random::())