From ae3d9bb66404d0514c2b096f47d0998fa802dea0 Mon Sep 17 00:00:00 2001 From: jeb Date: Wed, 25 Jul 2018 09:01:29 -0600 Subject: [PATCH] Fix compatibility warnings and errors in examples. --- examples/managed_queue/Cargo.toml | 2 +- examples/managed_queue/src/main.rs | 2 +- examples/pastebin/Cargo.toml | 2 +- examples/pastebin/src/paste_id.rs | 4 ++-- examples/todo/Cargo.toml | 2 +- examples/todo/src/tests.rs | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/managed_queue/Cargo.toml b/examples/managed_queue/Cargo.toml index 24f7fe59..24c6d294 100644 --- a/examples/managed_queue/Cargo.toml +++ b/examples/managed_queue/Cargo.toml @@ -4,6 +4,6 @@ version = "0.0.0" workspace = "../.." [dependencies] -crossbeam = "*" +crossbeam = "0.4" rocket = { path = "../../lib" } rocket_codegen = { path = "../../codegen" } diff --git a/examples/managed_queue/src/main.rs b/examples/managed_queue/src/main.rs index 7dd09c4e..7f3a73bd 100644 --- a/examples/managed_queue/src/main.rs +++ b/examples/managed_queue/src/main.rs @@ -6,7 +6,7 @@ extern crate rocket; #[cfg(test)] mod tests; -use crossbeam::sync::MsQueue; +use crossbeam::queue::MsQueue; use rocket::State; #[derive(FromForm, Debug)] diff --git a/examples/pastebin/Cargo.toml b/examples/pastebin/Cargo.toml index 907ff59a..99abbbaa 100644 --- a/examples/pastebin/Cargo.toml +++ b/examples/pastebin/Cargo.toml @@ -6,4 +6,4 @@ workspace = "../../" [dependencies] rocket = { path = "../../lib" } rocket_codegen = { path = "../../codegen" } -rand = "0.3" +rand = "0.5" diff --git a/examples/pastebin/src/paste_id.rs b/examples/pastebin/src/paste_id.rs index 83b7cf0a..96b39725 100644 --- a/examples/pastebin/src/paste_id.rs +++ b/examples/pastebin/src/paste_id.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rocket::request::FromParam; use rocket::http::RawStr; -use rand::{self, Rng}; +use rand::{self, RngCore}; /// Table to retrieve base62 values from. const BASE62: &'static [u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -20,7 +20,7 @@ impl<'a> PasteID<'a> { let mut id = String::with_capacity(size); let mut rng = rand::thread_rng(); for _ in 0..size { - id.push(BASE62[rng.gen::() % 62] as char); + id.push(BASE62[(rng.next_u32() % 62) as usize] as char); } PasteID(Cow::Owned(id)) diff --git a/examples/todo/Cargo.toml b/examples/todo/Cargo.toml index 7a3b3ebf..6eaa66e7 100644 --- a/examples/todo/Cargo.toml +++ b/examples/todo/Cargo.toml @@ -14,7 +14,7 @@ dotenv = "0.10" [dev-dependencies] parking_lot = {version = "0.4", features = ["nightly"]} -rand = "0.3" +rand = "0.5" [dependencies.rocket_contrib] path = "../../contrib" diff --git a/examples/todo/src/tests.rs b/examples/todo/src/tests.rs index 854e9ebd..206987d7 100644 --- a/examples/todo/src/tests.rs +++ b/examples/todo/src/tests.rs @@ -3,7 +3,7 @@ extern crate rand; use super::task::Task; use self::parking_lot::Mutex; -use self::rand::{Rng, thread_rng}; +use self::rand::{Rng, thread_rng, distributions::Alphanumeric}; use rocket::local::Client; use rocket::http::{Status, ContentType}; @@ -90,7 +90,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 = rng.gen_ascii_chars().take(12).collect(); + let desc: String = rng.sample_iter(&Alphanumeric).take(12).collect(); client.post("/todo") .header(ContentType::Form) .body(format!("description={}", desc))