From aaf2ab3634b767fccf45a23037e80dce09cd783c Mon Sep 17 00:00:00 2001 From: PeachyDelight Date: Sat, 11 Jun 2022 05:15:07 +0200 Subject: [PATCH] use once_cell --- Cargo.lock | 1 - Cargo.toml | 1 - src/id_generation.rs | 23 +++++++++-------------- src/main.rs | 3 --- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f15654..8e02690 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,7 +1100,6 @@ version = "0.1.0" dependencies = [ "futures", "futures-util", - "lazy_static", "once_cell", "rand 0.8.5", "serde", diff --git a/Cargo.toml b/Cargo.toml index c47dd84..029da94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,4 @@ serde_json = "1.0.68" tokio = { version = "1.12.0", features = ["full"] } tokio-stream = { version = "0.1.7", features = ["fs"] } warp = "0.3.1" -lazy_static = "1.4.0" rand = "0.8.5" diff --git a/src/id_generation.rs b/src/id_generation.rs index aca658f..65c0a5d 100644 --- a/src/id_generation.rs +++ b/src/id_generation.rs @@ -1,9 +1,8 @@ use std::collections::HashMap; +use once_cell::sync::Lazy; use rand::prelude::SliceRandom; - - const PLURALNOUN: [&'static str; 2847] = [ "Abilities", "Absences", @@ -5626,18 +5625,14 @@ const PATTERNS: [&str; 1] = [ // "_ADJECTIVE__PLURALNOUN_AtThe_PLACE_", ]; - - -lazy_static! { - static ref CATEGORIES: HashMap<&'static str, Vec<&'static str>> = { - let mut categories = HashMap::new(); - categories.insert("_PLURALNOUN_", Vec::from(PLURALNOUN)); - categories.insert("_VERB_", Vec::from(VERB)); - categories.insert("_ADVERB_", Vec::from(ADVERB)); - categories.insert("_ADJECTIVE_", Vec::from(ADJECTIVE)); - categories - }; -} +static CATEGORIES: Lazy>> = Lazy::new(|| { + let mut categories = HashMap::new(); + categories.insert("_PLURALNOUN_", Vec::from(PLURALNOUN)); + categories.insert("_VERB_", Vec::from(VERB)); + categories.insert("_ADVERB_", Vec::from(ADVERB)); + categories.insert("_ADJECTIVE_", Vec::from(ADJECTIVE)); + categories +}); // export function generateRoomWithoutSeparator() { diff --git a/src/main.rs b/src/main.rs index 4189fe4..bbabe4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate lazy_static; - use serde_json::json; use std::net::IpAddr;