diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e6bc7ed4..5c738078a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ code you contribute must be: * **Commented:** Complex or subtle functionality must be properly commented. * **Documented:** Public items must have doc comments with examples. - * **Styled:** Your code must folow the [Code Style Conventions]. + * **Styled:** Your code must follow the [Code Style Conventions]. * **Simple:** Your code should accomplish its task as simply and idiomatically as possible. * **Tested:** You must write (and pass) convincing [tests](#testing) for all @@ -68,7 +68,7 @@ If you spot an open issue that you'd like to resolve: 4. **Wait for a review, iterate, and polish.** If a review doesn't come in a few days, feel free to ping a maintainer. - Once somene reviews your PR, integrate their feedback. If the PR solves the + Once someone reviews your PR, integrate their feedback. If the PR solves the issue (which it should because you have passing tests) and fits the project (which it should since you sought feedback _before_ submitting), it will be _conditionally_ approved pending final polish: documentation (rustdocs, diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index a2ed3b40d..731b41422 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -62,7 +62,7 @@ parking_lot = "0.12" ubyte = {version = "0.10.2", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } figment = { version = "0.10.17", features = ["toml", "env"] } -rand = "0.8" +rand = "0.9" either = "1" pin-project-lite = "0.2" indexmap = { version = "2", features = ["serde"] } diff --git a/docs/guide/12-pastebin.md b/docs/guide/12-pastebin.md index 96176b12f..abb5a5c5a 100644 --- a/docs/guide/12-pastebin.md +++ b/docs/guide/12-pastebin.md @@ -182,9 +182,9 @@ Before we continue, we'll need to make a few design decisions. const BASE62: &[u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; let mut id = String::with_capacity(size); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for _ in 0..size { - id.push(BASE62[rng.gen::() % 62] as char); + id.push(BASE62[rng.random_range(0..62)] as char); } PasteId(Cow::Owned(id)) @@ -227,7 +227,7 @@ Before we continue, we'll need to make a few design decisions. ```toml [dependencies] ## existing Rocket dependencies... - rand = "0.8" + rand = "0.9" ``` Ensure that your application builds with the new code: diff --git a/docs/tests/Cargo.toml b/docs/tests/Cargo.toml index 3e906e1c5..bae0eb060 100644 --- a/docs/tests/Cargo.toml +++ b/docs/tests/Cargo.toml @@ -15,7 +15,7 @@ rocket = { path = "../../core/lib", features = ["secrets"] } rocket = { path = "../../core/lib", features = ["secrets", "json", "mtls"] } figment = { version = "0.10.17", features = ["toml", "env"] } tokio = { version = "1", features = ["macros", "io-std"] } -rand = "0.8" +rand = "0.9" [dev-dependencies.rocket_dyn_templates] path = "../../contrib/dyn_templates" diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index 24b9768bc..12b2a22e6 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -9,4 +9,4 @@ publish = false rocket = { path = "../../core/lib", features = ["json"] } [dev-dependencies] -rand = "0.8" +rand = "0.9" diff --git a/examples/chat/src/tests.rs b/examples/chat/src/tests.rs index 91ceb1a66..d879538af 100644 --- a/examples/chat/src/tests.rs +++ b/examples/chat/src/tests.rs @@ -1,7 +1,7 @@ use std::ops::Range; -use rand::{thread_rng, Rng}; -use rand::distributions::Alphanumeric; +use rand::{rng, Rng}; +use rand::distr::Alphanumeric; use rocket::http::{ContentType, Status}; use rocket::http::uri::fmt::{UriDisplay, Query}; @@ -22,9 +22,9 @@ async fn send_message<'c>(client: &'c Client, message: &Message) -> LocalRespons } fn gen_string(len: Range) -> String { - thread_rng() + rng() .sample_iter(&Alphanumeric) - .take(thread_rng().gen_range(len)) + .take(rng().random_range(len)) .map(char::from) .collect() } @@ -42,7 +42,7 @@ async fn messages() { // Generate somewhere between 75 and 100 messages. let mut test_messages = vec![]; - for _ in 0..thread_rng().gen_range(75..100) { + for _ in 0..rng().random_range(75..100) { test_messages.push(Message { room: gen_string(10..30), username: gen_string(10..20), @@ -98,7 +98,7 @@ async fn messages() { async fn bad_messages() { // Generate a bunch of bad messages. let mut bad_messages = vec![]; - for _ in 0..thread_rng().gen_range(75..100) { + for _ in 0..rng().random_range(75..100) { bad_messages.push(Message { room: gen_string(30..40), username: gen_string(20..30), diff --git a/examples/pastebin/Cargo.toml b/examples/pastebin/Cargo.toml index 382bc4098..e2b116729 100644 --- a/examples/pastebin/Cargo.toml +++ b/examples/pastebin/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] rocket = { path = "../../core/lib" } -rand = "0.8" +rand = "0.9" diff --git a/examples/pastebin/src/paste_id.rs b/examples/pastebin/src/paste_id.rs index 3f31a67b4..159e4a231 100644 --- a/examples/pastebin/src/paste_id.rs +++ b/examples/pastebin/src/paste_id.rs @@ -17,9 +17,9 @@ impl PasteId<'_> { const BASE62: &[u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; let mut id = String::with_capacity(size); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for _ in 0..size { - id.push(BASE62[rng.gen::() % 62] as char); + id.push(BASE62[rng.random_range(0..62)] as char); } PasteId(Cow::Owned(id)) diff --git a/examples/todo/Cargo.toml b/examples/todo/Cargo.toml index 3aac18746..6e921ea55 100644 --- a/examples/todo/Cargo.toml +++ b/examples/todo/Cargo.toml @@ -12,7 +12,7 @@ diesel_migrations = "2.0.0" [dev-dependencies] parking_lot = "0.12" -rand = "0.8" +rand = "0.9" [dependencies.rocket_sync_db_pools] path = "../../contrib/sync_db_pools/lib/" diff --git a/examples/todo/src/tests.rs b/examples/todo/src/tests.rs index 04b903399..c8f9da256 100644 --- a/examples/todo/src/tests.rs +++ b/examples/todo/src/tests.rs @@ -1,6 +1,6 @@ use super::task::Task; -use rand::{Rng, thread_rng, distributions::Alphanumeric}; +use rand::{self, Rng, distr::Alphanumeric}; use rocket::local::asynchronous::Client; use rocket::http::{Status, ContentType}; @@ -103,7 +103,7 @@ fn test_many_insertions() { for i in 0..ITER { // Issue a request to insert a new task with a random description. - let desc: String = thread_rng() + let desc: String = rand::rng() .sample_iter(&Alphanumeric) .take(12) .map(char::from)